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

GetSelectedCount shows wrong value

Hi.

I have data per month-end (stock-values per article)

If I set a filter on the month-end (say 6 months) the following happens:

  • selected article has values in all 6 months, GetSelectedCount(Period) shows 6
  • selected article has values NOT in all 6 months (e.g. only in 2), GetSelectedCount(Period) shows 2.

In both cases, the active filter, shown in the headline of Qliksense shows correctly (6 of 51 filtered periods)

Am I doing something wrong or should I use a different formula ?

Based on the result of GetSelectedCount(Period), other figures such as average-consumption, days-of-inventory, etc. are calculated.

Regards,

Reinhold

12 Replies
sunny_talwar

Then why were you looking for GetSelectedCount in the first place? I am confused, but may be you just need Count(Distinct Month)?

reinholdgraf
Creator
Creator
Author

Well, because this isn't working in a table per row, as shown in the attachement.

I need the no. of selected months, to calculate the average consumption in the selected period, not in the periods with data.

Sample:

Article has consumption of 100 in a single month (e.g. 2017-03).

Selected Periods: 2017 01-03 (3 months).

Correct Average Consumption per month: 100 / 3 = 33

Calculated Average Consumption per month as per the discussed formulas: 100 / 1 = 100.

Problems:

1) Wrong calculation

2) Filters in table not working anymore (don't understand that).

Solution now:

I created a variable with your formula  Count(DISTINCT {1<Period = $::Period>} Period)

and use this now in the table.

Works fine now.

Anyway, thanks for your patience and your help !

Reinhold

sunny_talwar

Got it, in that case, you can also use this

Count(TOTAL DISTINCT {1<Period = $::Period>} Period)