stack_pointer is EXTINCT
stack_pointer is EXTINCT

Reputation: 2393

Auto hide columns in Tableau

I have a requirement to calculate YoY % for each month e.g. % difference between May 2018 and May 2017, Apr 2018 and Apr 2017 .. so on. and show it as a column in Tableau.

I need to show this data only from Jan 2018 and cannot "filter" the date, as I still need to preserve them for YoY% calculataion. How can I do "auto-hide" for months before Jan 2018. I'd like to show only last 6 months and hide rest as we roll forward this year.

Upvotes: 0

Views: 3278

Answers (1)

Sam M
Sam M

Reputation: 4166

Create a calculated field that is a boolean value. The Y/N is whether the date is older than 6 months.

Suppose you create a calculated field called Is Old:

DATEDIFF("month", [Your Date]) > 6

Drag Is Old as a dimension. Right-click on the value in the data pane and instead of Exclude, choose Hide. Hiding keeps the value available for calculations but removes it from the display. If you want the data filtered rather than hidden, use the calculated field in a filter instead.

To make this an even better solution and more dynamic, create a parameter called Number of Months. Then use that in your calculated field, for example

DATEDIFF("month", [Your Date]) > [Number of Months]

Note: I have not tried this code as I don't have a datasource handy. It should get you in the right direction though.

Upvotes: 0

Related Questions