Skip to main content

I was using the calculated field month([Date])=month({max([Date])}), which i would drag to the filters shelf and choose 'True'.

So if for 2022 the data is available until January, Tableau would show me only January 2021 and January 2022. Now i want to view not just January but also December for both years 2022 and 2021, i.e. last month available going by the last available data as well as the previous month for both years i.e. 2022 and 2021.

Is there a way to modify the calculated field above to incorporate the previous month as well?

I tried using something like:

if month([Date])=month({max([Date])})

or month([Date])=month({max([Date])}-1)

then 'true' else 'false' end

and dragged to the filters shelf and chose true. But this does not seem to be working.

 

Is there a way to resolve this?

1 réponse
  1. 8 févr. 2022, 13:03

    Hi @Ambreen Firdous​ -

    You can alter the formula to the following:

    month([Date])=month({max([Date])})

    OR 

    month([Date])=month(DATEADD('month',-1,{max([Date])}))

     

    Let me know if you have any question. If the solution helps, do mark it as "Select as Best" thus it will be easier for others who seeks the same solution to find it in the future.

0/9000