Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Saurabh07
Contributor III
Contributor III

6 months trend for Top 5 countries based on date selected

Hello Gurus,

I have a bit of complex requirement, Ill try my best to make you all understand. I have the mentioned dataset used as back-end:

DateCountryValue
01-01-2020Australia4121
01-01-2020Germany1092
01-01-2020Italy2475
01-01-2020Jersey1548
01-01-2020Luxembourg2102
01-01-2020Netherlands1290
01-01-2020Singapore4142
01-01-2020Switzerland261528
01-01-2020United Kingdom10398
01-01-2020United States of America78009
01-02-2020Australia5024
01-02-2020country_unassigned30105
01-02-2020Germany5442
01-02-2020Luxembourg4924
01-02-2020Netherlands3677
01-02-2020Singapore3436
01-02-2020Switzerland18535
01-02-2020United Kingdom13358
01-02-2020United States of America89225
01-02-2020Virgin Islands (Brit)4277
01-04-2020Canada8823
01-04-2020country_unassigned48637
01-04-2020France11286
01-04-2020Germany11970
01-04-2020Japan7714
01-04-2020Luxembourg14027
01-04-2020Netherlands7277
01-04-2020Switzerland112202
01-04-2020United Kingdom37741
01-04-2020United States of America155936
01-05-2020Australia5388
01-05-2020country_unassigned318186
01-05-2020Germany5636
01-05-2020Luxembourg3127
01-05-2020Netherlands3327
01-05-2020Singapore3498
01-05-2020Switzerland20748
01-05-2020United Kingdom13776
01-05-2020United States of America90066
01-06-2020Virgin Islands (Brit)4046
01-06-2020Australia3458
01-06-2020Canada2739
01-06-2020country_unassigned343785
01-06-2020France2693
01-06-2020Germany5535
01-06-2020Luxembourg2450
01-06-2020Netherlands2882
01-06-2020Switzerland18619
01-06-2020United Kingdom9143
01-06-2020United States of America88556

Now I have filters at top, one for Current Date and another for Previous date. All I have done is created two states, Current and Previous and applied it to each of the filter.

I have a table for Top 6 countries sorted based on the current values;

Saurabh07_0-1603974789820.png

I am using mentioned expression for Current value and Previous value calculation:

Sum({[Current]}Value) and Sum({[Previous]}Value)

Now I need the 6 month trend of the same top 6 countries on line chart. The expression for dimension I used in Line chart is;

=aggr(if( rank(sum(Value))<7,Country),Country) 

Saurabh07_1-1603974865857.png

But the problem with this expression is the Top 5 countries are not same as those displayed in the table. I need to see Virgin Island (Brit) instead of Luxembourg in the line chart.

Can someone please help me with this ? Any help would be highly appreciated?

2 Replies
Brett_Bleess
Former Employee
Former Employee

Maybe the following Design Blog post may be of some help:

https://community.qlik.com/t5/Qlik-Design-Blog/Recipe-for-a-Pareto-Analysis-Revisited/ba-p/1473684

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
JeromeS
Partner - Contributor III
Partner - Contributor III

Hello,

Luxembourg is shown as a dimension because it is ranked in the overall top 6

if you want to display the same countries as in your table, you have to use the bookmarks/states Current and Previous in your calculated dimension aggr(if( rank(sum(Value))<7,Country),Country) 

you want to display the TOP 6 Countries for current value AND previous value so you want to the two states/selected dates in your set analysis. I am not an expert of the set expression but i would slightly change your formula in the following way:aggr(if( rank(sum({[Current]+[Previous]}Value))<7,Country),Country) and see it if works

 

https://help.qlik.com/en-US/sense/June2019/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/SetAnalys...

 

kind regards,

 

Jérôme