Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
paulyeo11
Master
Master

How to compute the net profit amount by oad script ?

Hi All

I have below load script working fine :-
If([GL_CODE_]>=5000001 and [GL_CODE_]<=5999999,'rEVENUE_P') as [rEVENUE_P],
If([GL_CODE_]>=6000001 and [GL_CODE_]<=6999999,'cOG_P') as [cOG_P],

I try to make use of load script to compute the net profit amount as below :-
If([GL_CODE_]>=5000001 and [GL_CODE_]<=5999999,'rEVENUE_P')-
If([GL_CODE_]>=6000001 and [GL_CODE_]<=6999999,'cOG_P') as [nET_P],

I get the return value = 0 which is wrong. Hope some one can advise me.

Paul

 

1 Solution

Accepted Solutions
rubenmarin

Hi, I don't know what you mean as the first is working fine.

That code assigns the string 'rEVENUE_P' to the field rEVENUE_P, that's the value it has: a string. Same for cOG_P field.

So you cant do math operations with strings

Maybe with:

Rangesum(If([GL_CODE_]>=5000001 and [GL_CODE_]<=5999999,Amount)
,-If([GL_CODE_]>=6000001 and [GL_CODE_]<=6999999,Amount) as [nET_P],

 

View solution in original post

1 Reply
rubenmarin

Hi, I don't know what you mean as the first is working fine.

That code assigns the string 'rEVENUE_P' to the field rEVENUE_P, that's the value it has: a string. Same for cOG_P field.

So you cant do math operations with strings

Maybe with:

Rangesum(If([GL_CODE_]>=5000001 and [GL_CODE_]<=5999999,Amount)
,-If([GL_CODE_]>=6000001 and [GL_CODE_]<=6999999,Amount) as [nET_P],