# New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
New 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

Thanks

8 Replies
Honored Contributor II

## Re: Addition and Subtraction of fields to form a new field

Hi,

Can you attach the sample data in text file?

New Contributor III

## Re: Addition and Subtraction of fields to form a new field

Hi,

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

Thanks

Honored Contributor II

## Re: Addition and Subtraction of fields to form a new field

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

New Contributor III

## Re: Addition and Subtraction of fields to form a new field

Hi Arjun,

But I need

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

Rangesum() is not helping me in minus.

Honored Contributor

## Re: Addition and Subtraction of fields to form a new field

Try like this

=RangeSum(Column1,Column2,-Column3)

MVP

## Re: Addition and Subtraction of fields to form a new field

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

Honored Contributor II

## Re: Addition and Subtraction of fields to form a new field

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

Best Regards,
KC
MVP & Luminary

## Re: Addition and Subtraction of fields to form a new field

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:

Revenue,

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

FROM ... your data source ...

;

CONCATENATE (Revenue)

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