Victoria Ubaldo
Victoria Ubaldo

Reputation: 99

Tableau - How sum values with 12 last months

in Tableau I have a table with this form :

rows: Score.

columns:MY(month), sum(good), sum(bad).

This is the information when I use: month 201811

        201611     201612   ...  201801 ...  201811  TOTAL
Score  Good Bad   Good Bad    Good Bad ...  Good Bad 
1      3    0      7    3       6   3        2    1
2      5    1      1    1       1   1        4    4
3      10   3      2    1       0   3        3    3

I want to use a filter with 'Month' column ,when I filter month=201811, show since 201611 to 201711 (last 12 months) in Total column(Totals in Bad and Good columns) by Score.

Filter: 201811
Formula: sum(Good) and sum(Bad) since '201611' to '201711'

I trying "IF DATEDIFF('month', [Good], today()) <=12" but doesn't work.

Thanks for your help.

Upvotes: 0

Views: 310

Answers (1)

wavery
wavery

Reputation: 279

Try this:

If DATEDIFF("month",TODAY(),[Your Date Field],"Sunday") <= -12
then [Your Date Field] else null end

Then use that as your date column. The "Sunday" is supposed to be whatever you consider the starting day of the week. I wasn't sure what your date field is named so I named it "[Your Date Field]"

Upvotes: 1

Related Questions