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

How to select current dimension value

Hi ,


I want to create a bar graph visualization using Year as a dimension.
Each bar should be calculated as: Current Year (vol) / Prev Year (vol) 
I am unable to fetch the Prev Year value.
Could you please explain how can I write an expression which will take the current dimension value and subtract 1 from it to get the Prev year?

Thank you

Labels (5)
6 Replies
Taoufiq_Zarra

@User0  Did you test GetFieldSelections :

https://help.qlik.com/en-US/qlikview/May2021/Subsystems/Client/Content/QV_QlikView/ChartFunctions/Fi...

and use -1 to get previous year for selected value ?

Regards,
Taoufiq ZARRA

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

(you can mark up to 3 "solutions") 😉
User0
Contributor III
Contributor III
Author

Hi Taoufiq,

It needs to be a static graph, I do not want to change it as per the year selection from the filter. 
It should show me the data from the years 2010-2022. No option to choose any year.

Thankyou

vikasmahajan

Hi  you need to write set analysis like following :

 

 

Current Year Sales

 

=Sum({<Year = {'$(=Max(Year))'}>} Sales)

 

Or

 

By Formula use

=Sum({<Year = {"$(vCurrYr)"}>} Sales)

 

 

Previous Year Sales

 

=Sum({<Year = {'$(=Max(Year)-1)'}>} Sales)

 

Or

 

By Formula Use

=Sum({<Year = {"$(vPrevYr)"}>} Sales)

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
User0
Contributor III
Contributor III
Author

Hi @vikasmahajan ,
Thank you for your suggestion but it did not work how I wanted it to .
Attaching a demo graph to show , each year should show a bar with the formula as (Current year volume - Prev year volume) and the year is the dimension in the graph .
The two separate bars are for different brands.
By using the above formulas, I am only seeing graph for the current year and previous year(coming up as blank).

Thankyou

User0_0-1652766470699.png

User0_1-1652766495703.png

 

 

vikasmahajan

Can you please attach some sample data to help you 😉

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
User0
Contributor III
Contributor III
Author

Brand Year Vol
     
A 2021 3456
A 2022 5434
B 2021 5434
B 2022 546
V 2021 435
V 2022 5345
K 2021 4234
K 2022 435
W 2021 54
W 2022 654

Hi @vikasmahajan , I have multiple brand data yearly. Attaching sample data for you.