Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (17.6k points)

I am using a number inside a calculation and have to turn it into a string. When I do this, I lose the comma formatting. Using another post:

Changing Number Format in a String

However the formula, I am using

STR(ROUND(LOOKUP(sum([Actual]),0),0))

It does not seem to be working. The full calculation is here: 

If attr([Kpi Nm]) = "Policy Retention Better-than-State Average"

    Then str(round(sum([Actual]) * 100, 2)) + "%"

ElseIf attr([Kpi Nm]) = "Policy Retention Improvement (or > 90%)**"

    Then str(round(sum([Actual]) * 100, 2)) + "%"

Elseif attr([Kpi Nm]) = "Premium Growth"

    Then str(round(sum([Actual]) *100, 2)) + "%"

Elseif attr([Kpi Nm]) = "PIF Growth"

    Then str(round(sum([Actual]), 2))

Elseif attr([Kpi Nm]) = "Product Density"

    Then "NA"

else

   STR(ROUND(LOOKUP(sum([Actual]),0),0))

End

I need to keep the commas on the Actual for the else statement. Any help provided would be much appreciated. The Lookup is supposedly a trick to make it work but does not work in my case.

Thanks 

1 Answer

0 votes
by (47.2k points)

Tableau's regex implementation supports this particular type of expression though it needs to look ahead. Use it with the regular expression to replace function.

(\d)(?=(\d{3})+$)

Firstly register yourself in an industry-recognized Tableau Desktop Certification such as you can register for our Tableau Training online.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 29, 2019 in BI by Ashok (47.2k points)

Browse Categories

...