0

I am trying to recreate an index chart with Tableau (https://mbostock.github.io/protovis/ex/index-chart.html) for Makeover Monday 2021 W17 data set, and I cannot figure out what is the best approach to do this. I am using Tableau Public so I cannot attach the workbook as a document but you can find it here : https://public.tableau.com/views/RemakingMakeoverMondayW17IndexChart/Sheet14?:language=en-US&publish=yes&:display_count=n&:origin=viz_share_link

The data set contains every state in the US and a price index for that state between the years 2008-2019. I want to create a line chart which would use a selected year as a comparison condition, and would show the difference between each year and the selected year.

My approach was the following:

  1. I created a parameter for date "Year Parameter".

  2. I created a calculated field "PARAMETER YEAR" to give me price index for the selected parameter date:

IF [Year] = [Year Parameter] THEN [Price Index] END

  1. I tried to calculate the difference and that is where I get stuck: SUM([Price Index]) - SUM([PARAMETER YEAR]). This calculation shows me only 1 state for the selected year.

Any ideas on how to deal with this?

1 Answer 1

0

try this for your reference index:

{EXCLUDE [Year], [Regions], [Description]   : sum(
    IF DATEPART('year', [Year])= DATEPART('year', [Year Parameter]) THEN [Price Index]
         ELSE 0   
END)}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot, I spend hours on this but it works great now! In the end I did have to remove [Regions] from your calculation because it was just giving one line that summed all of the states, so the final calculation was: {EXCLUDE [Year], [Description] : sum( IF DATEPART('year', [Year])= DATEPART('year', [Year Parameter]) THEN [Price Index] ELSE 0 END)}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.