Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
stevietm
Creator
Creator

Subtract two percentages from each other

Hi All,

I would just like to know if it is possible to subtract two percentages from each other in a straight table. For example i have 3 columns that uses MAT variables to calculate MAT MS in %. First column = MAT-2 MS%, second column = MAT-1 MS% and third column = CY MAT MS%.

So what i want is to subtract MAT-1 MS% from MAT-2 MS%. Example below.

MS
MAT -2
MS
MAT -1
% Subtracted
29.68%31.25%1.57%
0.00%3.06%3.06%
13.03%12.33%-0.70%

I have tried to use the variables and subtract them from each other but its not giving me the growth or decline between the 2 percentages.

If someone knows how to do this please let me know.

Thanks in advance.

Regards

Stevie

13 Replies
marwen_garwachi
Creator II
Creator II

You can load MAT -1 and MAT -2 in your script as a single column  and  then you can substract them later on your Table.


Hope it will help you.

Marwen 

Not applicable

Hi,

check the attached QVW.

stevietm
Creator
Creator
Author

Hi

I am using this as a variable "sum(if (Inmonths (12,Time, SetDateYear (LatestMonthPrevYr, max (total Year (Time))), 0,10), Value))" to calculate MAT in a straight table as i do not have MAT MS% in my data. I need to calculate the MAT MS and then subtract them as i only have values in my data.

Hope i am making sense, or i am just not understanding.

Thanks

Regards

Stevie

stevietm
Creator
Creator
Author

Please see screen shot. This is my table that i exported to excel from qlikview.

The percentage i get back from subtracting the MAT MS is not correct.

Thanks

Regards

Stevie

simondachstr
Luminary Alumni
Luminary Alumni

Create 2 expressions in a straight table

MS            MS

MAT -2      MAT -1


Then, create a third expression and simply type in

Column(1)-Column(2)


Or alternatively you can also specify the expressions directly instead of using column(1) and column(2)


stevietm
Creator
Creator
Author

Hi,

That does not work i have tried - the last 2 columns where used column one - column two.

I will try writing out the whole expression.

Thanks

Regards

Stevie

simondachstr
Luminary Alumni
Luminary Alumni

If there are values in column 1 and column 2, the expression column(1)-column(2) will subtract those values.

Can you explain your sentence "the last 2 columns where used column one - column two"

stevietm
Creator
Creator
Author

Hi Martin,

Yes you are correct it will subtract the values when i use column(1)-column(2). This is not what i want, i need it to subtract the % from each other to get a % growth or decline between the 2 percentages. Not the value % growth or decline.

My sentence: The last 2 columns in my screen shot i used the expression column(1)- column(2), which is not working.

Thanks

Regards

Stevie

Not applicable

Stevie, is not subtracting what you want? Can't see why Martins idea wouldn't work for you.

You have just said you want to take [MS MAT-1] - [MS MAT -2] and get the result in a %, which you should be able to do with what Martin has said. Can you explain further, or better yet upload an example?