Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Help with expression

How can i write this if statement in the set analysis present in the below expression.

expression:

if(sum(total<GENDERFLAG,Color>  itno28)=0,0,sum({<flag28={1}>}total <Style,Color,GENDERFLAG,Size> PDFC20*factor20*Avg12MonthsSalesPrice))

In the above expression sum( total<GENDERFLAG,Color> itno28 is my condition to check in if statement but is there any way i can use this is set analysis. The issue i am getting is please see attached screen shots.

1 Solution

Accepted Solutions
Nicole-Smith

Have a look at the attached.

sum(aggr(if(sum(total<Color>itno28)=0,0,sum({<flag28={1}>} total <Color,GENDERFLAG,Style> PDFC20*factor20*Avg12MonthsSalesPrice)),Color))

View solution in original post

8 Replies
Nicole-Smith

Maybe:

sum({<flag28={1},itno28={'sum(total<GENDERFLAG,Color> itno28)=0'}>}total <Style,Color,GENDERFLAG,Size> PDFC20*factor20*Avg12MonthsSalesPrice)

If that doesn't work, maybe try replacing the underlined itno28 with another one of your fields...

Also, are you sure you don't need the flag28={1} inside of the sum() in the set analysis?

Anonymous
Not applicable
Author

Hi Nicole, Thanks for you fast reply. I tried your expression but i am getting all zeros. Below is the expression i have used.

sum({<flag28={1},itno28={'sum(total<GENDERFLAG,Color>  itno28)=0'}>}total <Style,Color,GENDERFLAG,Size> PDFC20*factor20*Avg12MonthsSalesPrice)

Also i flag28=1 that flag is required in the set analysis. Please let me know if you need any additional information. Thanks for all your help.

Nicole-Smith

Did you try replacing the underlined itno28 with another one of your fields?  Try it with a few of them and see if it makes a difference.

sum({<flag28={1},itno28={'sum(total<GENDERFLAG,Color>  itno28)=0'}>}total <Style,Color,GENDERFLAG,Size> PDFC20*factor20*Avg12MonthsSalesPrice)

If that doesn't work, you'll need to post a .qvw: Preparing examples for Upload - Reduction and Data Scrambling

Anonymous
Not applicable
Author

Hi Nicole, attached is the qlikview document please let me know if you need further information.

Nicole-Smith

Have a look at the attached.

sum(aggr(if(sum(total<Color>itno28)=0,0,sum({<flag28={1}>} total <Color,GENDERFLAG,Style> PDFC20*factor20*Avg12MonthsSalesPrice)),Color))

Anonymous
Not applicable
Author

Thank you for your help let me apply this expression and get back to you .

Anonymous
Not applicable
Author

Hi Nicole, you made my day... thanks a lot man..............................................

Nicole-Smith

You're welcome.  I'm glad it works