0
votes

I have a dataset that sometimes comes with a field (LTV) using number like 83.5 to represent 83.5%, and sometimes with numbers like 0.835.

To avoid that issue, I want to create a calculated field that divides the original rows by 100 in case the average of the field is more than 3, and leaves it without changes in the other case.

The formula that I use to do that is:

IF AVG([LTV])<3 THEN [LTV] ELSE [LTV]/100 END

In order to avoid the error in comparison between aggregated and non-aggregated fields, I changed it to:

IF {AVG([LTV])<3} THEN [LTV] ELSE [LTV]/100 END

The problem is that Tableau is giving me an aggregated field as a result. What I want is to compare every single row to the average of the whole column in order to make every decision. How can I do that?

I already tried to create a new column that contains the resulting average of the whole column repeated in each row, but I don't know how. Any suggestions?

1

1 Answers

0
votes

I would check for the decimal location instead of the amount. This way there is no aggregation.

Try this:

if find(str([Ltv]),"0")=1 then [Ltv] else [Ltv]/100 end