4 Replies Latest reply on Jul 24, 2013 12:49 PM by Aishwarya Balamukundan

# IF statement for percentages in Calculated field

Hi there,

I am trying to color code Y/Y percentages and I am facing some issues:

Y/Y is a calculated field - number format being % and no decimal places.

IF [Y/Y Actual]>= 1 THEN

"Positive"

ELSEIF [Y/Y Actual] < -1 THEN

"Negative"

ELSE

"No Change"

END

I use this calculated filed for the color coding.

Somehow this isn't working for me- in the sense that if its a -ve % it goes to negative  I tried including 'ELSEIF Y/Y =0', it did not work either.

It would be great if anyone could help me out! I guess I am having a dumb moment

Aishwarya

• ###### 1. Re: IF statement for percentages in Calculated field

It is possible you may need to write the formula as

IF SUM([Y/Y Actual])>= 1 THEN

"Positive"

ELSEIF SUM([Y/Y Actual]) < -1 THEN

"Negative"

ELSE

"No Change"

END

Also, if you post a packaged workbook or some sample data that is similar to what you have, this problem would be easier to troubleshoot.

• ###### 2. Re: Re: IF statement for percentages in Calculated field

Well, I tried that too. The Y/Y Actual is already a calculated field, so I cannot aggregate over an agg. function.

I have attached a sample workbook in which I duplicated my problem.

Thanks,

Aish

• ###### 3. Re: Re: Re: IF statement for percentages in Calculated field

Aishwarya,

You'll need to multiply your profit ratio in your color calculation by 100 to get the percentages. Once you've done that, you can assign colors to the discrete values that are the result of your calculation. I attached my edits to your workbook below.

-Dylan

• ###### 4. Re: Re: IF statement for percentages in Calculated field

Hi Dylan, worked on my original source perfectly fine ! Thanks so much!