# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Now
cancel
Showing results for
Did you mean:
Highlighted Not applicable

## 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

1 Solution

Accepted Solutions
Highlighted MVP

## 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))

6 Replies
Highlighted MVP

## 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))

Highlighted Not applicable

## 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

Highlighted MVP

## 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))

Highlighted Not applicable

## 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)

Cheers -sv

Highlighted Partner

## 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

Highlighted MVP

## Re: If statement within set analysis

Great, if you got what you were looking for, I would suggest closing this thread by marking correct and helpful responses.

Qlik Community Tip: Marking Replies as Correct or Helpful

Best,

Sunny