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: 
TDQlik
Contributor III
Contributor III

Comparing 2 different values in the same table in a visual

Hi,

I am trying to achieve a situation where I can select 2 values and then be able to see the comparison between them.

For example I want to select 2 seasons and be able to see the sales performance of those 2 seasons and the differences between them. I don't want all my visuals to change to those 2 seasons and their totals, but their performance by dimension. For example I want a user to select a season and then a season to compare that season to.

Is this achieved through variables? Extensions? Any help would be appreciated. Thank you.

Regards

Labels (1)
1 Solution

Accepted Solutions
GaryGiles
Specialist
Specialist

The easiest way accomplish this without affecting other visuals in your application to create 2 variables, for example, vSelectedSeason1 and vSelectedSeason2.   Then, using a Variable Input custom object from the Qlik Dashboard bundle, add 2 drop down list box options, one for each variable.  For Values, select "Dynamic" and use the following as the definition:  =Concat(Distinct Season,'|').

Then for your measures to compare your 2 season, use:

sum({$<[Season]={$(vSelectedSeason1)}>} ValueField)

sum({$<[Season]={$(vSelectedSeason2)}>} ValueField)

Difference between them:

sum({$<[Season]={$(vSelectedSeason2)}>} ValueField) - sum({$<[Season]={$(vSelectedSeason1)}>} ValueField)

Hope that helps.  You will need to use that appropriate field names in your data model.

View solution in original post

2 Replies
GaryGiles
Specialist
Specialist

The easiest way accomplish this without affecting other visuals in your application to create 2 variables, for example, vSelectedSeason1 and vSelectedSeason2.   Then, using a Variable Input custom object from the Qlik Dashboard bundle, add 2 drop down list box options, one for each variable.  For Values, select "Dynamic" and use the following as the definition:  =Concat(Distinct Season,'|').

Then for your measures to compare your 2 season, use:

sum({$<[Season]={$(vSelectedSeason1)}>} ValueField)

sum({$<[Season]={$(vSelectedSeason2)}>} ValueField)

Difference between them:

sum({$<[Season]={$(vSelectedSeason2)}>} ValueField) - sum({$<[Season]={$(vSelectedSeason1)}>} ValueField)

Hope that helps.  You will need to use that appropriate field names in your data model.

TDQlik
Contributor III
Contributor III
Author

Hi Gary,

I found this solution indeed before your answer, but thanks anyway this is what worked!

Regards