Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Percentage calculation using variables

I have the following two variables with the values tested in text boxes:

Screen Shot 2015-11-23 at 17.16.13.pngScreen Shot 2015-11-23 at 17.15.57.png

I am trying to get the % change from current versus the previous as follows:

=$(vSetCurrentAvRevRx)/$(vSetPreviousAvRevRx) - 1 and formatted as a percentage in number tab option

which should give -1.56% but i am getting a different value (-.99999).  My expression above should be the problem.  Kindly assist.

Regards

Message was edited by: Christopher Chitemerere

18 Replies
tamilarasu
Champion
Champion

Chirstopher, Add equal sign like below.

=($(=vSetCurrentAvRevRx)/$(=vSetPreviousAvRevRx) )- 1


Or you can prefix equal sign (=) before num syntax in your both current and previous expressions and try below


=($(vSetCurrentAvRevRx)/$(vSetPreviousAvRevRx) )- 1

Anonymous
Not applicable
Author

are your sure that your variables are correct.

Test them in case of

Not applicable
Author

Hi Christopher

here a qvw

best regards

chrisitan

Anonymous
Not applicable
Author

Thanks Tamil, i get an error:  Error in expression

Anonymous
Not applicable
Author

The values returned by the variables are give in the textboxes posted in my initial post.

Anonymous
Not applicable
Author

Many thanks, you are on the right track you missed the -1 and should be as follows:

Num(

((Sum({$<$(vSetMTD)>}[MedAid Amount]) +Sum({$<$(vSetMTD)>}[Shortfall]))/Sum({$<$(vSetMTD)>}Rx))

/

((Sum({$<$(vSetPreviousMonth)>}[MedAid Amount]) + Sum({$<$(vSetPreviousMonth)>}[Shortfall]))/Sum({$<$(vSetPreviousMonth)>}Rx)) - 1,

'# ##0,00 %')


This give the correct value as posted in my initial post.  I am however looking as using the variables.

tamilarasu
Champion
Champion

Ok.Did you try the second solution. Go to variable window and add equal sign in your expressions like below

Current

=Num((Sum({$<$(vSetMTD)>}[MedAid Amount])) + Num(Sum({$<$(vSetMTD)>}[Shortfall])), '$##,##0.00')/Num(Sum({$<$(vSetMTD)>}Rx), '#,##0')

Previous

=Num((Sum({$<$(vSetPreviousMonth)>}[MedAid Amount])) + Num(Sum({$<$(vSetPreviousMonth)>}[Shortfall])), '$##,##0.00')/Num(Sum({$<$(vSetPreviousMonth)>}Rx), '#,##0')


And try


=($(vSetCurrentAvRevRx)/$(vSetPreviousAvRevRx) )- 1

Anonymous
Not applicable
Author

Thank you Christian, i will look at the qvw

Regards.

Anonymous
Not applicable
Author

Hi Tamil

Tried the second option above and gives a blank