1 Reply Latest reply on Jul 23, 2014 11:59 AM by Darin Coulter

# How to format percent in a range/string to 2 decimal places in a If statement calculated field?

Hi! I would like to create a new field to capture the range of the Min & Max sales growth% in this format:  38.12% - 65.85% if they are different.

If the min and max are the same, display only the min (e.g. 38.12%).

Currently, the sales growth data looks like this : 0.12, 0.258, 0.2368, 0.1254

I created a calculated field but.....did not work:

If    min([salesGrowth]) = max ([salesGrowth])

Then str(round(min([SalesGrowth]),2))+'%'

Else str(round(min([salesGrowth],2))+'% - " str(round(max([salesGrowth],2)+'%'

End

• ###### 1. Re: How to format percent in a range/string to 2 decimal places in a If statement calculated field?

I used the Superstore sales extract and the Product Base Margin measure and used a similar IF statement:

IF MIN([Product Base Margin]) = Max([Product Base Margin])

THEN str((Round(min([Product Base Margin])*100, 2)))+"%"

ELSE str((Round(min([Product Base Margin])*100, 2)))+"%-"+str((Round(max([Product Base Margin])*100, 2))) + "%"

END

I think this will get you close.