6 Replies Latest reply: Sep 28, 2016 1:05 PM by Sunny Talwar

# If statement within set analysis

Hi,

I'm struggling to make my set analysis expression to work. I'm trying to get the total time where ordernumber is equals to the choosen ordernumber on my filter pane and requestdescription is not blank. Here's my code:

sum ({1<[OrderNumber]=P({\$<[OrderNumber]={"if(len(trim([RequestDescription]))>0,

[OrderNumber])"}>}[OrderNumber])>}

num#((Interval([StpDate]-[StrtDate], 'ss'))/60/60))

Appreciate any inputs or suggestions... Thanks in advance. -sv

• ###### Re: If statement within set analysis

Can you try this:

Sum({1<[OrderNumber]=P([OrderNumber])>} Num#((Interval([StpDate]-[StrtDate], 'ss'))/60/60))

or

Sum({1<[OrderNumber] = \$::[OrderNumber])>} Num#((Interval([StpDate]-[StrtDate], 'ss'))/60/60))

• ###### Re: If statement within set analysis

Hi Sunny,

Thanks for the quick response. Yes, I tried it and its working but I also need to check on the "RequestDescription" if its not blank then I could add the date and get the sum for it.

Actually here's my previous code that was working just need to add the check for the "RequestDescription"...

sum ({1<[OrderNumber]=P({\$}[OrderNumber])>}

num#((Interval([StpDate]-[StrtDate], 'ss'))/60/60))

-sv

• ###### Re: If statement within set analysis

May be this:

Sum({1<[OrderNumber]=P([OrderNumber]) * {"=Len(Trim(RequestDescription)) > 0"}>} Num#((Interval([StpDate]-[StrtDate], 'ss'))/60/60))

• ###### Re: If statement within set analysis

He could also create a Flag in the script for checking for Null or empty values in the SA

• ###### Re: If statement within set analysis

Hi Sunny,

Here's what I did and it worked:

sum ({1<[OrderNumber]=P({\$<"if(len(trim([RequestDescription]))>0, [OrderNumber])">})>}

num#((Interval([StpDate]-[StrtDate], 'ss')))/60/60)