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: 
bharatkishore
Creator III
Creator 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
Champion
Champion

Hi,

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

olivierrobin
Specialist III
Specialist III

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
Creator III
Creator III
Author

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
Specialist III
Specialist III

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
Creator III
Creator III
Author

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
Specialist III
Specialist III

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