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: 
Not applicable

if condition that doesn't work

hey everyone i am trying to set an if condition but for some reason it dosen't work:

if sum({$<YEAR={'$(=max(YEAR-1))'}>}RIV_QUANT)>0 and

sum({$<YEAR={'$(=max(YEAR-1))'}>}NIS_TOTPRICE)>0 and

(sum ({$<Year={'YEAR'}>}RIV_QUANT))<1 and

(sum ({$<Year={'YEAR'}>}NIS_TOTPRICE))<1,(sum ({$<Year={'YEAR'}>}NIS_TOTPRICE))

RIV_QUANT=quantatiy

NIS_TOTPRICE=sales

1 Solution

Accepted Solutions
Not applicable
Author

Hey everyone ,

the script line that finaliy work was:

if (

     sum({$<YEAR={'$(=max(YEAR)-1)'}>}RIV_QUANT)>0

     and sum({$<YEAR={'$(=max(YEAR)-1)'}>}NIS_TOTPRICE)>0

     and sum ({$<YEAR={'$(=max(YEAR))'}>}RIV_QUANT)<1

     and sum ({$<YEAR={'$(=max(YEAR))'}>}NIS_TOTPRICE)<1,

     sum ({$<YEAR={'$(=max(YEAR))'}>}NIS_TOTPRICE),sum ({$<YEAR={'$(YEAR)'}>}NIS_TOTPRICE)

     )

thank you all for helping!!

View solution in original post

9 Replies
Not applicable
Author

here is a link to the original file:

clinton key table6.qvf - Google Drive 

sunny_talwar

I don't know if this is just a typo when you were posting it here, or if this is something you missed in your original expression, but you are missing a parenthesis and two extra parenthesis in your expression:

=If(Sum({$<YEAR={'$(=Max(YEAR-1))'}>} RIV_QUANT) > 0 and

     Sum({$<YEAR={'$(=Max(YEAR-1))'}>} NIS_TOTPRICE) > 0 and

     Sum ({$<Year={'YEAR'}>} RIV_QUANT)) < 1 and

     Sum ({$<Year={'YEAR'}>} NIS_TOTPRICE)) < 1,

     Sum ({$<Year={'YEAR'}>} NIS_TOTPRICE))

Not applicable
Author

Hey sunny i do understand what your saying  but for some reason it's not working,

can't you try using my link to find out the problem?

Not applicable
Author

Hi,

Not sure If I have understood what you want to do maybe you can try this expression :

if (sum({$<YEAR={'$(=max(YEAR)-1)'}>}RIV_QUANT)>0 and sum({$<YEAR={'$(=max(YEAR)-1)'}>}NIS_TOTPRICE)>0 and sum ({$<YEAR={'$(=max(YEAR))'}>}RIV_QUANT)<0 and sum ({$<YEAR={'$(=max(YEAR))'}>}NIS_TOTPRICE)<0,sum ({$<YEAR={'$(=max(YEAR))'}>}NIS_TOTPRICE),0)

This works if you select a YEAR and if not it is taken the MAX (YEAR)

Regards

Gilles

Not applicable
Author

what i am trying to show its which customers had sales on 2014 ( for example) but stopped buying in 2015 ( for example)

Not applicable
Author

for some reason the reason you gave me didn't work

clinton key table6.qvf - Google Drive

Not applicable
Author

Hi,

If you want those that did not buy anything you should put <=0 instead of <0 for the current year. Also It works for me as I put Customer as dimension. if you want to use it in a graph without Customer as Dimension you need to do an aggr expression.

Can you tell me more how you want to use it ? Maybe in you qvf add a new sheet (in english please) with what you are trying to do ?

Regards

Gilles

reddy-s
Master II
Master II

Hi Jhonatan,

Are you using this in the script or as an expression of a measure?

Not applicable
Author

Hey everyone ,

the script line that finaliy work was:

if (

     sum({$<YEAR={'$(=max(YEAR)-1)'}>}RIV_QUANT)>0

     and sum({$<YEAR={'$(=max(YEAR)-1)'}>}NIS_TOTPRICE)>0

     and sum ({$<YEAR={'$(=max(YEAR))'}>}RIV_QUANT)<1

     and sum ({$<YEAR={'$(=max(YEAR))'}>}NIS_TOTPRICE)<1,

     sum ({$<YEAR={'$(=max(YEAR))'}>}NIS_TOTPRICE),sum ({$<YEAR={'$(YEAR)'}>}NIS_TOTPRICE)

     )

thank you all for helping!!