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: 
Not applicable

Retrieve data for the past 7 year in bar chart using set analysis

I want to retreive data for the past 7 year i.e if the current is 2017 then I need to get data from 2017 to 2000 in bar chart using set analysis.Can some one please suggest.

6 Replies
bouderbc
Creator
Creator

Hi,


to get data from 2017 to 2000 in bar chart using set analysis:


1-Dimension: Year

2-Measure:


sum({$<Year= {"2011"}+{"2012"}+{"2013"}+{"2015"}+{"2016"}+{"2017"}>} [Sales])


Or  Solution 2:  Sum({$ < Year ={"200*"}> } [Sales ])


Anonymous
Not applicable
Author

Hi,

you can create this set analysis:

sum({<Year={'>=$(=max(Year)-7)'}>} Sales)

This will get the maximum year-7.

Output:

 

Yearsum({<Year={'>=2010'}>} Sales)
2010500
2011800
2012600
2013800
2014400
2015300
2016200
2017200
Anil_Babu_Samineni

Do you mean 2017 to 2010, assume typo error

May be this?

Sum({$<year = {">=$(=AddYears(Max(year),-7)) <=$(=Year(Today()))"}>}Sales) //This will return last 7 years of sales

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anil_Babu_Samineni

yddona.lyn


This will work until year has 2017. What if year field has forecast data

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anil_Babu_Samineni

bouderbc


this way also not correct, Because - you are using static data on your set expression for first approach

And Second approach is will return only starting of 200 of year data - 2000, 2001, .... 2009

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
adamdavi3s
Master
Master

This will only work if the user wants to return data based on today's year

You're close but what you actually want to make it completely dynamic is

Sum({$<Year = {">=$(=AddYears(Max(Year),-7)) <=$(=Max(Year))"}>}Sales)