Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
bharatkishore
Contributor III

Expression help

Hi All,

i Have the below expression written in script:

 

    (if(if(IsNull(YTD_Consumption_LY),0,YTD_Consumption_LY)=0,if(IsNull(Cons_YTD_LY),0,-Cons_YTD_LY),

    if(IsNull(Cons_YTD_LY),0,-Cons_YTD_LY))*(ADJ_CONS_YTD_LY/YTD_Consumption_LY)) as Adj_Consumption,

I am getting the value as 467K

Now when i write the below expression in text box i.e.

=sum(if(if(IsNull(YTD_Consumption_LY),0,YTD_Consumption_LY)=0,if(IsNull(Cons_YTD_LY),0,-Cons_YTD_LY),

    if(IsNull(Cons_YTD_LY),0,-Cons_YTD_LY)))*(sum(ADJ_CONS_YTD_LY)/sum(YTD_Consumption_LY)) 

  

   

i am gettiing the value i.e. 568K

Can you please help me where i am doing wrong in my script expression..

Thanks,

Bharat

6 Replies
YoussefBelloum
Esteemed Contributor

Re: Expression help

Hi,

would you be able to attach sample data or sample app ?

olivierrobin
Valued Contributor II

Re: Expression help

hello

maybe the 2 sum() functions in your 2nd expression

if i understand, the 1st one i equivalent to a*b . if you sum, it is sum(a*b)

and in the 2nd, it is more sum(a)*sum(b)

which is mathematically different

bharatkishore
Contributor III

Re: Expression help

Hi Robin,

The correct formula is:

=sum(Cons_YTD_LY)*(sum(ADJ_CONS_YTD_LY)/sum(YTD_Consumption_LY))..

I need to represent this in

(if(if(IsNull(YTD_Consumption_LY),0,YTD_Consumption_LY)=0,if(IsNull(Cons_YTD_LY),0,-Cons_YTD_LY),

    if(IsNull(Cons_YTD_LY),0,-Cons_YTD_LY))*(ADJ_CONS_YTD_LY/YTD_Consumption_LY))

Can you please tell where i am doing wrong

olivierrobin
Valued Contributor II

Re: Expression help

the 1st one can be resumed as sum(a)*sum(b)/sum(c)

so you have to express your 2nd one on the same format, maybe like

sum(if( ........,a))*sum(if( .......,b))/sum(if( .......,c))

where if(....) is your if formulas and a,b,c, the 3 expressions you want to sum

bharatkishore
Contributor III

Re: Expression help

Hi,

I am just writing a simple expression as below:

Cons_YTD_LY*(ADJ_CONS_YTD_LY/YTD_Consumption_LY) but still the value is not matching..

Can you please let me know where iam doing wrong

olivierrobin
Valued Contributor II

Re: Expression help

you have to write your if() expressions

if(......,Cons_YTD_LY)*if(........,ADJ_CONS_YTD_LY)/if(......,YTD_Consumption_LY)

unless there are the same for each member, and is this case

if(........,Cons_YTD_LY*(ADJ_CONS_YTD_LY/YTD_Consumption_LY))