Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
krishna20
Specialist II
Specialist II

Set analysis with if else

Hi,

Can anyone tell me tat how can we write conditional and else statements in a single expression using set analysis.

Regards

krishna

19 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Can you come up with an example and sample output?

Regards,

Jagan.

krishna20
Specialist II
Specialist II
Author

Hi here is my expression.i'm getting output for only if condtion.Its not moving to another if.

=if(CE_CLOSE_YN='1' and CE_CLOSE_DT<Today(),0,if(CE_CLOSE_YN='1' and CE_CLOSE_DT>Today(),(sum({$<Year={"vCurrentYear-2>vCurrentYear-1<vCurrentYear"}>}CE_AMT_LC_1))))

Regards

Krishna

SunilChauhan
Champion II
Champion II

if(CE_CLOSE_YN='1' and CE_CLOSE_DT<Today(),0,if(CE_CLOSE_YN='1' andCE_CLOSE_DT>Today(),(sum({$<Year={"vCurrentYear-2>vCurrentYear-1<vCurrentYear"}>}CE_AMT_LC_1)), elsepartexpression

)


)

and chcek breakets

Sunil Chauhan
krishna20
Specialist II
Specialist II
Author

Hi Sunil,

thank you for your reply..

In the above expression the second part is my expression its not working.The condition stops with first If condition itself.The else condition is the below one.

if(CE_CLOSE_YN='1'andCE_CLOSE_DT>Today(),(sum({$<Year={"vCurrentYear-2>vCurrentYear-1<vCurrentYear"}>}CE_AMT_LC_1))


Regards

Krishna

VishalWaghole
Specialist II
Specialist II

Hello Kalyan,

Check your CE_CLOSE_DT and Today () format is matching or not.

also check without if statement your set analysis is working or not.

- Regards,

Vishal Waghole

krishna20
Specialist II
Specialist II
Author

Thank You Vishal

Regards

Krishna

its_anandrjs

Try like

=if(CE_CLOSE_YN='1' and CE_CLOSE_DT<Today(),0,

(sum({$<Year={"vCurrentYear-2>vCurrentYear-1<vCurrentYear"}>}CE_AMT_LC_1)))


Or


=if( (CE_CLOSE_YN ='1' and CE_CLOSE_DT < Today()),0,

if( (CE_CLOSE_YN ='1' and CE_CLOSE_DT > Today()),(sum({$<Year={"vCurrentYear-2>vCurrentYear-1<vCurrentYear"}>}CE_AMT_LC_1))))

SunilChauhan
Champion II
Champion II

if(CE_CLOSE_YN='1' and CE_CLOSE_DT<Today(),0,if(CE_CLOSE_YN='1' andCE_CLOSE_DT>Today(),(sum({$<Year={"vCurrentYear-2>vCurrentYear-1<vCurrentYear"}>}CE_AMT_LC_1))), you right here your else part or another if)



as you have already two if one for 0 and other for set expression i.e Sum(....),

HPH


Sunil Chauhan
krishna20
Specialist II
Specialist II
Author

Hi Sunil,

Thank You for your Reply.

My Expression is totally like above.In that i need to check two conditions.The second if condition and sum will be in else part.

Regards

Krishna