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: 
Lucius_Artorius_Castus

When we select multiple options from filter, get the only maximum selected option from filter pane.

Hi, I am implementing functionality where when i select multiple options from filter pane, I have bar chart where I am showing yearly data so I want to only show the maximum month-year data from the selection per year,

Lucius_Artorius_Castus_0-1709187895856.png

Right now it should only show Apr-2021 data, i select option from 2021 and 2022 then it should show the 2 bar with maximum month from selection.

Thanks, let me know it is possible or not.

Labels (2)
2 Solutions

Accepted Solutions
LRuCelver
Partner - Creator III
Partner - Creator III

You don't need the Only():

SUM(
    {<[CREATED_DATE-Year-Month]={$(=Concat(Aggr(Chr(39) & Max([CREATED_DATE-Year-Month]) & Chr(39), Year([CREATED_DATE-Year-Month])), ','))}>} 
    [FA_QTY_FUNC] * [AVERAGE_PRICE]
)

View solution in original post

LRuCelver
Partner - Creator III
Partner - Creator III

This expression always returns the sum for the latest possible [CREATED_DATE-Year-Month]. No set analysis or complex Aggrs needed:

FirstSortedValue(Aggr(Sum([FA_QTY_FUNC] * [AVERAGE_PRICE]), [CREATED_DATE-Year-Month]), -[CREATED_DATE-Year-Month])

 It also works with the "year" as the dimension:

Aggr(Year([CREATED_DATE-Year-Month]), [CREATED_DATE-Year-Month])

View solution in original post

10 Replies
LRuCelver
Partner - Creator III
Partner - Creator III

Please clarify:

  • always show data from all possible years
  • show data from all possible months combined if there is no [Month-Year] selection
  • show data from the largest month selected for every year if there is a [Month-Year] selection
    • If Apr-2023 and Jun-2022 are selected what should be shown:
      • Apr-2023 and Jun-2022 or Jun-2023 and Jun-2022 or Apr-2023 and Apr-2022?
Lucius_Artorius_Castus
Author

@LRuCelver Thanks for replying,

By default if no selection made right now I am showing the data of latest month for specific year, year is dimension
for example:- for 2021 i am showing data of 2021 dec,
                      for 2022 I am showing data of 2022 dec.
for 2024 I am showing data for 2022 Feb ( which is latest month data in 2024) so this is working perfectly right now,
Now I need to handle the scenario when selection made if there is one selection made let's say 2021-jun then bar should only show data for 2021-jun,
But multiple selection made then let's say 2021-jun, 2021-july then it should show the data of 2021-july
another scenario is if   2021-jun, 2021-july, 2022-jan, 2022-feb then it should show 2 bars, 1st for 2021 where data should be 2021-july and 2nd for 2022 where data should be 2022-feb.

I know this is complex but let me know if you get it or not.
Thanks

LRuCelver
Partner - Creator III
Partner - Creator III

This shows the only remaining Year-Month for every Year after applying the set analysis:

{<[Month-Year]={$(=Concat(Aggr(Chr(39) & Max([Month-Year]) & Chr(39), Year), ','))}>}
Only([Month-Year])

Replace the Only() expression with whatever you need it to be.

Here are the results for multiple selections over different years:

LRuCelver_0-1709199849324.png

 

Lucius_Artorius_Castus
Author

@LRuCelver this is what I want, i tried above expression but when I selecte more than one selection chart is not showing up, this is my expression
SUM({<[CREATED_DATE-Year-Month]={$(=Concat(Aggr(Chr(39) & Max([CREATED_DATE-Year-Month]) & Chr(39), Year([CREATED_DATE-Year-Month])), ','))}>} Only([FA_QTY_FUNC] * [AVERAGE_PRICE]))

Let me know what changes I should make it to work

Thanks

LRuCelver
Partner - Creator III
Partner - Creator III

You don't need the Only():

SUM(
    {<[CREATED_DATE-Year-Month]={$(=Concat(Aggr(Chr(39) & Max([CREATED_DATE-Year-Month]) & Chr(39), Year([CREATED_DATE-Year-Month])), ','))}>} 
    [FA_QTY_FUNC] * [AVERAGE_PRICE]
)
Lucius_Artorius_Castus
Author

Lucius_Artorius_Castus_0-1709289539864.png

Still not working with bar chart, maybe because of year dimension?
This is the expression im using for dimension year Year([CREATED_DATE-Year-Month])

Lucius_Artorius_Castus_1-1709289597948.png

 

LRuCelver
Partner - Creator III
Partner - Creator III

You are correct.

You need to add a new field [CREATED_DATE-Year] using Year([CREATED_DATE-Year-Month]) as the calculation expression in the script to the data model.

 

Lucius_Artorius_Castus
Author

Ok but right now I don't have option of script, I have only one option with chart expression, is there anything we can do about it?

LRuCelver
Partner - Creator III
Partner - Creator III

This expression always returns the sum for the latest possible [CREATED_DATE-Year-Month]. No set analysis or complex Aggrs needed:

FirstSortedValue(Aggr(Sum([FA_QTY_FUNC] * [AVERAGE_PRICE]), [CREATED_DATE-Year-Month]), -[CREATED_DATE-Year-Month])

 It also works with the "year" as the dimension:

Aggr(Year([CREATED_DATE-Year-Month]), [CREATED_DATE-Year-Month])