# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

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

I think your code will also work.Really appreciate your help.

Cheers -sv 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 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