Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
amijit_hazarika
Contributor III
Contributor III

Addition and Subtraction of fields to form a new field

Hi All,

I have created a column which will show 4 revenue values. I am doing it in script.

With all conditions fulfilled I was able to get the 1st three fields;

1. Total Part Revenue = If(Geo = 'Coast', 'Total Part Revenue') as Total_Measure

2. Total Revenue from Outside = If(Geo <> 'Coast', 'Total Revenue from Outside') as Total_Measure

3. Less Revenue = If(Geo <> 'Coast', Region = 'Aus', 'Less Revenue') as Total_Measure


4. Overall Revenue = 1st Field + 2nd Field - 3rd Field.


I am struggling to get the 4th field. Any input would be of great help.

Total_MeasureRevenue
Total Part Revenue150
Total Revenue from Outside70
Less Revenue20
Overall Revenue(1st Field + 2nd Field - 3rd Field)200

stalwar1stevedark

Thanks

8 Replies
qlikviewwizard
Master II
Master II

Hi,

Can you attach the sample data in text file?

amijit_hazarika
Contributor III
Contributor III
Author

Hi,

My Organisation doesnt allow me to upload any data. However I have showed the sample possible data in the above question.

Thanks

qlikviewwizard
Master II
Master II

Use RangeSum(Total Part Revenue,Total Revenue from Outside,Less Revenue)

Hope this will help you.

amijit_hazarika
Contributor III
Contributor III
Author

Hi Arjun,

But I need

Total Part Revenue + Total Revenue from Outside - Less Revenue.

Rangesum() is not helping me in minus.

shiveshsingh
Master
Master

Try like this

=RangeSum(Column1,Column2,-Column3)

sunny_talwar

This is something you are looking to do in the script or front end of the app?

jyothish8807
Master II
Master II

How did you map the revenue to the corresponding dimension values ?

Best Regards,
KC
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Your best bet is probably going to be calculating it in the front end, but if you do want to do it in script you need to do the load from the data twice, with a concatenate, i.e.

Revenue:

LOAD

  Revenue,

  ... your if statements here ... as Total_Measure

FROM ... your data source ...

;

CONCATENATE (Revenue)

LOAD

  Revenue,

  'Overall Revenue' as Total_Measure

FROM ... your data source ...

;

The massive risk and disadvantage of this approach is that all of the revenue will be double counted, so if you do a sum(Revenue) in the front end, without Total_Measure as a dimension you will get wrong values.

Not doing the concatenate, and having each value once would remove this risk.  You can then use the Total feature in Sense tables to show a totals row.

Hope that helps.

Steve