Search code examples
data-visualizationbusiness-intelligencetableau-desktop

Tableau add filter inside calculated field


In Tableau i have a calculated field like this below:

COUNTD( 
IF(
MONTH([Dataevent]) == 4
) THEN [Id] end)
/
COUNTD( 
IF(
YEAR([Dataevento]) == 2018
) THEN [Id] end)

i would like to add a filter to automatically select from the sheet the month and the year without hardcoding them, like this:

COUNTD( 
IF(
MONTH([Dataevent]) == filter
) THEN [Id] end)
/
COUNTD( 
IF(
YEAR([Dataevento]) == filter
) THEN [Id] end)

how should i do?


Solution

  • You can do it with parameters.

    You have to

    1. create a parameter
    2. use it inside your calculated field
    3. Add a filter control to the parameter

    You can find a good tutorial following this link.