Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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

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

Anonymous
Not applicable
Author

='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
Creator II
Creator II

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])

Anonymous
Not applicable
Author

value in rupees is = avg(wheat2)

ramkrishna86
Creator II
Creator II

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

OmarBenSalem

maybe

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

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

Anonymous
Not applicable
Author

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

what do you mean?

Anonymous
Not applicable
Author

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