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

finding percentage % difference between 2 sums

Hi

I need to find the % different between 2 sums, i have tried a few things but never get the calculated result below. 

sum({<[Year]={'2019'}>} [HKD_Price])

and

sum({<[Year]={'2018'}>} [HKD_Price]) 

The figures are as follows and so know the difference must like below

2760530389.02

1504520710.05

58.8978% difference

 

Please can you assist in the expression to reach this result?

Thank you in advance

Daniel

Labels (1)
1 Solution

Accepted Solutions
Kushal_Chawda

may be try this

=(sum({<[Year]={'2019'}>} [HKD_Price]) - sum({<[Year]={'2018'}>} [HKD_Price]) )/sum({<[Year]={'2018'}>} [HKD_Price]) 

or

(1- sum({<[Year]={'2019'}>} [HKD_Price]) / sum({<[Year]={'2018'}>} [HKD_Price]))*-1

View solution in original post

6 Replies
Taoufiq_Zarra

58.8978% is correct ?

and only from

2760530389.02

1504520710.05

 

?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Kushal_Chawda

may be try this

=(sum({<[Year]={'2019'}>} [HKD_Price]) - sum({<[Year]={'2018'}>} [HKD_Price]) )/sum({<[Year]={'2018'}>} [HKD_Price]) 

or

(1- sum({<[Year]={'2019'}>} [HKD_Price]) / sum({<[Year]={'2018'}>} [HKD_Price]))*-1
davyqliks
Specialist
Specialist
Author

Hi,

The figure is correct when i work outside of QV but i cannot make an expression to obtain the correct Value, thank you for the reply, if you have the solution please help.

Thank you in advance

Daniel

Kushal_Chawda

Looking at the values we won't be able to know what is the logic to get the %. A general % difference formula is already suggested. Please provide some sample data with logic to calculate % difference

davyqliks
Specialist
Specialist
Author

HI,

Thank you for this, not sure i worded right but once i made the figures smaller this made sense.

Thank you

 

alexblagoveshchenskiy
Contributor
Contributor

Dear Kush,

 

Could you please correct me if i'm wrong.

But is there are any other option to calculate it? 
My aggregation still incorrect. 

 

Formula:

NUM(
(
(
sum({<[line_sku] = {$(=chr(34) & concat(distinct [temp_all_FF_struc.line], chr(34)&','&chr(34)) & chr(34))},d_type = {'target'}, yr_q = {'$(vYr)_$(vQ)'}>}pcs * $(vPLGF))
-
sum({<[line_sku] = {$(=chr(34) & concat(distinct [temp_all_FF_struc.line], chr(34)&','&chr(34)) & chr(34))},d_type = {'fact'}, yr_q = {'$(vYr_p)_$(vQ)'}>}pcs * $(vPLGF))
)
/ sum({<[line_sku] = {$(=chr(34) & concat(distinct [temp_all_FF_struc.line], chr(34)&','&chr(34)) & chr(34))},d_type = {'target'}, yr_q = {'$(vYr)_$(vQ)'}>}pcs * $(vPLGF))
)
, '#0%')

 

 

alexblagoveshchenskiy_0-1617383552918.png

 

 

 

Thank you in advance!