# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for
Did you mean:
Highlighted 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
Highlighted MVP

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],``````

Highlighted MVP

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],`````` 