0
votes

I'm trying to create calculated field in tableau, my below query is showing valid, however I want to give filter or parameter to it. For ex: I have a field called Account number and I want my below query to show sum of all the quarters revenue on account number level.

Sum(If ([Qtr]='2019-Q1' OR [Qtr]='2019-Q2' OR [Qtr]='2019-Q3' OR [Qtr]='2019-Q4') 
THEN FLOAT([Revenue]) END)
2
Thought logic used in both will be same.Athreyas
Please just tag the actual RDBMS you are interested in. People don't appreciate over tagging.Dale K
I've removed them for you, please add back the single RDBMS of interest.Dale K

2 Answers

0
votes

Your logic will work. For parameter: Create a parameter with String data type, add all field names to it. Then create a calculated field based on the parameter list. Add that calculated field to row shelf then change Parameter, the above formula will be recalculated. For Filter: You can add filter directly.

0
votes

1st option:

Add Account number as row in your worksheet

Create a Parameter String with values: 2019-Q1, 2019-Q2, 2019-Q3, 2019-Q4

Update your calculated field to:

If [Qtr]='Parameter Value' THEN FLOAT([Revenue]) END

Add this field as text and the value of sum will be for only that Qtr period

2nd option:

Add Account number as row in your worksheet

Create a Parameter String with values: 2019-Q1, 2019-Q2, 2019-Q3, 2019-Q4

Update your calculated field to:

[Qtr]='Parameter Value'

Add this field to the filters and the whole worksheet will filter on that Qtr period

You can also add another parameter for the year to be more flexible on the years