Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

reinholdgraf
Contributor

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

1 Solution

Accepted Solutions
MVP
MVP

Re: GetSelectedCount shows wrong value

Not sure if I understand completely, but can you use this

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

12 Replies
rahulpawarb
Valued Contributor II

Re: GetSelectedCount shows wrong value

Hello Reinhold,

Could you please share the application with sample data?

Regards!

Rahul

reinholdgraf
Contributor

Re: GetSelectedCount shows wrong value

I attached a sample-qvf where the situation is easily shown.

I also attach a screenshot showing the problem.

MVP
MVP

Re: GetSelectedCount shows wrong value

I was surprised by your observation. I would expect GetPossibleValues() to respond to the number of possible months -- I would not have expected GetSelectedCount to respond as well.

However, if you have a Period list box open when you select that item, you will see that only 2 of the periods will be green-highlighted, so both the listbox and GetSelectedCount seems to only consider selections from the possible values only.

I think you will need to find another way to get that count.

reinholdgraf
Contributor

Re: GetSelectedCount shows wrong value

Yes, that's right.

Both (GetSelectedCount and GetPossibleValues) respond 2.

MVP
MVP

Re: GetSelectedCount shows wrong value

Not sure if I understand completely, but can you use this

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

reinholdgraf
Contributor

Re: GetSelectedCount shows wrong value

Could you kindly explain this formula as the result is ok now, but for some reason, other filters on the table (e.g. article) do not work anymore.

MVP
MVP

Re: GetSelectedCount shows wrong value

This specific expression ignores all selections except for selection in Period field. What exactly are you looking to get?

karthiksrqv
Contributor II

Re: GetSelectedCount shows wrong value

Hi,

Do you think it could be a version problem?

I opened your Test.qvf in my Qliksense Desktop 3.2 SR1 version and I see 1 in both (the built-in filter on top and the Getselectedcount)

reinholdgraf
Contributor

Re: GetSelectedCount shows wrong value

pls see attachement.

When using your formula, Filter set for Articles isn't working anymore and formula is only working for total table, not per row. But I need the formula-result per line as this is the basis for further calculations.

It seems, that we need a different approach as this is geeting complicated...