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

How to Count on a dimension and not include the dimension in chart

Hello,

I have an issue. I need to count number of occurrences and represent it in a pie chart. The issue i am facing is the count have to be by two fields which will not be included on the chart. I have similar data for multiple Group Id's and for each Group Id i need to show the results in one table.

For example: Below is by raw data: I need to count only the rows marked in red.

GroupIDResultGroup IDDate
Group 11539041325/22/2013
Group 11539046325/22/2013
Group 215390414211/20/2013
Group 215390464211/20/2013
Group 315390413210/4/2012
Group 315390413.529/17/2013
Group 315390463210/4/2012
Group 315390463.529/17/2013
Group 41539041329/27/2012
Group 415390463.529/27/2012
Group 515390413.527/8/2012
Group 51539046327/8/2012
Group 615390413.523/17/2014
Group 61539046323/17/2014
Group 715390412.529/28/2012
Group 71539041328/11/2013
Group 715390462.529/28/2012
Group 71539046328/11/2013
Group 815390413.521/24/2014
Group 815390463.521/24/2014

The result i want is

ResultCount_resultTotal_Count
3716
3.5716
4216

Any help?

Thanks in advance.

1 Solution

Accepted Solutions
JonnyPoole
Employee
Employee

Here is a solution

Dimension:  Result

Count Rows Expression:

sum(aggr( if( Date = max( total <Group> Date) , 1, 0) , Result, Group,[Group ID],ID,Date))

Grand Total Expression:

if ( sum(aggr( if( Date = max( total <Group> Date) , 1, 0) , Result, Group,[Group ID],ID,Date)) > 0 ,

  sum( total aggr( if( Date = max( total <Group> Date) , 1, 0) , Result, Group,[Group ID],ID,Date))

)

Capture.PNG.png

View solution in original post

6 Replies
Anonymous
Not applicable
Author

I'm not seeing it: What determines whether a row should be counted or not?

oknotsen
Master III
Master III

Do you mean count the situations in which the combination of Result and Date is unique?

May you live in interesting times!
Not applicable
Author

Count the situation where the combination of maximum date and ID is unique for a group.

for example:

in Group 3, we only count two rows where Date is 9/17/2013 ( as this is maximum in Group 3)  for each ID

Group 315390413.529/17/2013
Group 315390463.529/17/2013

Hope this helps

maxgro
MVP
MVP

see attachment

JonnyPoole
Employee
Employee

Here is a solution

Dimension:  Result

Count Rows Expression:

sum(aggr( if( Date = max( total <Group> Date) , 1, 0) , Result, Group,[Group ID],ID,Date))

Grand Total Expression:

if ( sum(aggr( if( Date = max( total <Group> Date) , 1, 0) , Result, Group,[Group ID],ID,Date)) > 0 ,

  sum( total aggr( if( Date = max( total <Group> Date) , 1, 0) , Result, Group,[Group ID],ID,Date))

)

Capture.PNG.png

Not applicable
Author

Thanks Massimo Grossi and Jonathan Poole. It worked.