Qlik Community

Qlik Sense Cloud Discussions

ismqui00
New Contributor III

Calculated Field

I need to create a "Net Sales" field.  Should be pretty simple, as Subtotal and Coupon Total already exist, just need to add them for the net sale value.  Any help to solve this problem is appreciated.  So basically I need information on how to create a function that represents "Net Sales" =[Subtotal]+[Discount] so that I can use net sale field when creating reports.

2 Replies
Partner
Partner

Re: Calculated Field

Hello Ism!

Example if you use KPI to show your result, can be use:

=Sum([Subtotal])+Sum([Discount])

You will sum total values in your field considerated your filter.

see more about this function here!

I help you?! Pls mark correct answer.

Highlighted
sibin_jacob
Contributor III

Re: Calculated Field

I am assuming  [Subtotal] and [Discount] column already available in the same table,

you can just add both columns for creating the new column.

Please use the below  script,

Load

[Subtotal],

[Discount] ,

[Subtotal]+[Discount]  as [Net Sales]

From QVD_NAME;


If any one of the column having null values, use the below script,


Load

[Subtotal],

[Discount] ,

if(isnull([Subtotal]),0,Subtotal]))+if(isnull([Discount]),0,[Discount])  as [Net Sales]

From QVD_NAME;


Or you can use the Rangesum function to add two column values.


Load

[Subtotal],

[Discount] ,

Rangesum([Subtotal],[Discount] ) as [Net Sales]

From QVD_NAME;