9 Replies Latest reply on Oct 17, 2016 12:41 PM by Alex Xu

# I really need help on creating an "if" statement

I am trying to get a total count using a COUNT and an IF statement in order to get a total for each record that has a severity rating greater than 7.

I have tried using filters as well as I tried the following statements however I continue to get different errors on it or the outcome is incorrect:

COUNT([Record Number]):then (IF [Severity Rating]>7 then 1 else 0 end))

COUNT([Record Number]) if [Severity Rating]>7 then 1 elseif <8 then 0 end end

• ###### 1. Re: I really need help on creating an "if" statement

Yvette,

I think something like the first example you gave might work if you use sum instead of count.  It will count a zero as a records....but if you sum them, and only the applicable ones equal 1 then you might get what you're looking for.  I'm not positive without a workbook but it's worth a shot.

-Hope

• ###### 2. Re: I really need help on creating an "if" statement

you can try to use level of details:

{include [Record Number]: SUM(IF [Severity Rating]>7 THEN 1 ELSE 0 END)}

• ###### 3. Re: I really need help on creating an "if" statement

I think you can probably just create a very simple calculated field as follows:

Severity7

IF [Severity Rating]>7 then 1 else 0 end

And then on your ROWS shelf, just place your Customer field, and the new calculated field, Severity7, and just make sure that the measure calculation that's being used is SUM.  So, your viz might look something like this:

• ###### 4. Re: I really need help on creating an "if" statement

Hi Hope - I get the following error when I change it from Count to Sum:

• ###### 5. Re: I really need help on creating an "if" statement

Hi Alex when I tried this it gave me the same inflated totals.

• ###### 7. Re: I really need help on creating an "if" statement

You can't use the If then quite like that in an LOD.
kaz's option looks like a good one.

the formula might need to be something like this.  Hard to say for sure without the data to try it on.

SUM(IF severity rating >7 then 1 else o end)

Hope

• ###### 9. Re: I really need help on creating an "if" statement

can you attach a sample file?

Thanks,
Alex