Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

pranavgohil
New Contributor III

how to find the difference between measures of two selected bars in barchart?

example:

i want to find difference as

value in rupees in-

1984 = 43.44

1991 = 39.22

difference between them = 43.44 - 39.22 = 4.22

please help

difference example.PNG

16 Replies
omarbensalem
Esteemed Contributor

Re: how to find the difference between measures of two selected bars in barchart?

as a title or sub-title:

='difference btwn '&max(Year)& ' and '& min(Year)&' ='& (sum({<Year={"$(=max(Year))"}>}Expression1) - sum({<Year={"$(=min(Year))"}>}Expression1))

result:

Capture.PNG

pranavgohil
New Contributor III

Re: how to find the difference between measures of two selected bars in barchart?

='difference btwn '&max(Year)& ' and '& min(Year)&' ='

& (sum({<Year={"$(=max(Year))"}>}avg(Wheat2)) - sum({<Year={"$(=min(Year))"}>}avg(Wheat2)))

so this is my query after your suggestion but i want the average here in expression but its not allowing nested aggregation here.. please help

ramkrishna86
Contributor II

Re: how to find the difference between measures of two selected bars in barchart?

Just calculate max(year) and min(year) and write expression like this.

sum({<Year={"$(=max(Year))"}>}[value in rupees]) - sum({<Year={"$(=min(Year))"}>}[value in rupees])

pranavgohil
New Contributor III

Re: how to find the difference between measures of two selected bars in barchart?

value in rupees is = avg(wheat2)

ramkrishna86
Contributor II

Re: how to find the difference between measures of two selected bars in barchart?

Create new field in load script using avg(wheat2) as "Value in rupees" and use the same in formula as above mentioned.

omarbensalem
Esteemed Contributor

Re: how to find the difference between measures of two selected bars in barchart?

maybe

='difference btwn '&max(Year)& ' and '& min(Year)&' ='

& (avg({<Year={"$(=max(Year))"}>}(Wheat2)) - avg({<Year={"$(=min(Year))"}>}(Wheat2)))

pranavgohil
New Contributor III

Re: how to find the difference between measures of two selected bars in barchart?

sorry but i forgot to say, i'm using alternate states in this charts so if u have any way of doing that using alternate states..??

omarbensalem
Esteemed Contributor

Re: how to find the difference between measures of two selected bars in barchart?

what do you mean?

pranavgohil
New Contributor III

Re: how to find the difference between measures of two selected bars in barchart?

check the qvf i've uploaded to understand the query..