Qlik Community

Ask a Question

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Welcome to our newly redesigned Qlik Community! Read our blog to learn about all the new updates: READ BLOG and REPORTED ISSUES
cancel
Showing results for 
Search instead for 
Did you mean: 
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

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

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