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

Count Currented Selection Dimension

Hi,

I am try to do custom report as (https://community.qlik.com/t5/Qlik-Design-Blog/Qlik-Sense-Custom-Report/ba-p/1471797) and count total row for each dimension what I select. I stuck to calculate it.
Could you please help/suggest to resolve this issue?

Thanks,
Adam

1 Solution

Accepted Solutions
jaibau1993
Partner - Creator III
Partner - Creator III

Hi!

I suppose that you whant to fill the KPI Objects but I dont know how you want to fill them.

On the first hand

IF(GetSelectedCount(Dimension)='Address',
count({<Address=-{''}>}DimensionNo))

GetSelectedCount returns an integer with count of selections made in the field Dimension (so it will never be equal to 'Address'). If you want to count addresses when 'Address' record of the field 'Dimension' is selected, then try something like

If(Index(GetFieldSelections(Dimension, '|'), 'Address'), Count(Address))

Regards,

Jaime.

View solution in original post

6 Replies
jaibau1993
Partner - Creator III
Partner - Creator III

Hi!

I suppose that you whant to fill the KPI Objects but I dont know how you want to fill them.

On the first hand

IF(GetSelectedCount(Dimension)='Address',
count({<Address=-{''}>}DimensionNo))

GetSelectedCount returns an integer with count of selections made in the field Dimension (so it will never be equal to 'Address'). If you want to count addresses when 'Address' record of the field 'Dimension' is selected, then try something like

If(Index(GetFieldSelections(Dimension, '|'), 'Address'), Count(Address))

Regards,

Jaime.

jaibau1993
Partner - Creator III
Partner - Creator III

On the other hand, check your syntax:

IF(GetSelectedCount(Dimension)='State' or 'Address' or 'Age' or 'Email Address' or 'Job Title' ,Count(DimensionNo))

The above expression is incorrect, 'or' does not work this way. You should have write

IF(GetSelectedCount(Dimension)='State' or 'GetSelectedCount(Dimension)=Address' or 'GetSelectedCount(Dimension)=Age' or 'GetSelectedCount(Dimension)=Email Address' or 'GetSelectedCount(Dimension)=Job Title' ,Count(DimensionNo))

Jaime.

adambrian
Contributor III
Contributor III
Author

Hi Jaibau,

Thank for your quickly respond. For the If(Index(GetFieldSelections(Dimension, '|'), 'Address'), Count(Address))  is correct.. 

The second not function. I want to count like first one but with multiple selection.  For example, i select "Age" and "Address".   
If(Index(GetFieldSelections(Dimension, '|'), 'Age'), Count({<Age=-{''}>}Age),0) + If(Index(GetFieldSelections(Dimension, '|'), 'Address'), Count({<Address=-{''}>}Address),0) 

adambrian
Contributor III
Contributor III
Author

It there any way to simplify this syntax?

If(Index(GetFieldSelections(Dimension, '|'), 'Address'), Count({<Address=-{''}>}Address),0) +
If(Index(GetFieldSelections(Dimension, '|'), 'Age'), Count({<Age=-{''}>}Age),0) +
If(Index(GetFieldSelections(Dimension, '|'), 'Email Address'), Count({<EmailAddress=-{''}>}EmailAddress),0) +
If(Index(GetFieldSelections(Dimension, '|'), 'Job Title'), Count({<JobTitle=-{''}>}JobTitle),0) +
If(Index(GetFieldSelections(Dimension, '|'), 'State'), Count({<State=-{''}>}State),0)

jaibau1993
Partner - Creator III
Partner - Creator III

Hi

I've been thinking for a while on how to simplify this expression but i dont' see a beautiful way to solve it!

Jaime.

adambrian
Contributor III
Contributor III
Author

Hi,

Thank for your help Jaime