Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

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

Re: if condition that doesn't work

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

9 Replies
Not applicable

Re: if condition that doesn't work

here is a link to the original file:

clinton key table6.qvf - Google Drive 

MVP
MVP

Re: if condition that doesn't work

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

Re: if condition that doesn't work

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

Re: if condition that doesn't work

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

Re: if condition that doesn't work

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

Not applicable

Re: if condition that doesn't work

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

clinton key table6.qvf - Google Drive

Not applicable

Re: if condition that doesn't work

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

reddys310
Honored Contributor II

Re: if condition that doesn't work

Hi Jhonatan,

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

Not applicable

Re: if condition that doesn't work

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