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

Question about how Aggr works

I'm trying to count the number of months with at least 1 issue. And then divide that by the total number of months present in the data.

This formula allows me to count the total number of months: count(DISTINCT {<status={'issued'}>}Month). Refer to below left table for raw data and the right table for the calculated value.

This formula allows measure the max number of months in the dataset: Max(Aggr(count(DISTINCT {<status={'issued'}>}Month),stationID)). It returns 12 in this case.

However when I divide the first equation by the second equation in a table, where one of the dimensions is stationID, i dont get the expected output of formula1  / 12. Instead  is either 100% or NULL.

Qlik Help Image.png

I'm not sure why I'm getting this output, any help would be appreciated! I imagine it must be something do with how the aggregated formula reacts to the stationID dimension?

1 Solution

Accepted Solutions
bme
Partner - Contributor III
Partner - Contributor III

The outer aggregation on your function is still calculated using the table dimensions. Since your Aggr is done by stationID and that same field is used as your dimension it's doing a max for each stationID which is why you're getting 100%'s. You need the total modifier to get the max for the whole set.

count(DISTINCT {<status={'issued'}>}Month)/

Max(TOTAL Aggr(count(DISTINCT {<status={'issued'}>}Month),stationID))


View solution in original post

4 Replies
ogautier62
Specialist II
Specialist II

Hi,

if you've got NULL may be try to add NODISTINCT before aggr

regards

sunny_talwar

What if you just use this

Count(TOTAL <stationID> DISTINCT {<status={'issued'}>}Month)

bme
Partner - Contributor III
Partner - Contributor III

The outer aggregation on your function is still calculated using the table dimensions. Since your Aggr is done by stationID and that same field is used as your dimension it's doing a max for each stationID which is why you're getting 100%'s. You need the total modifier to get the max for the whole set.

count(DISTINCT {<status={'issued'}>}Month)/

Max(TOTAL Aggr(count(DISTINCT {<status={'issued'}>}Month),stationID))


Anonymous
Not applicable
Author

Thanks Ben for the clear explanation of what I was doing wrong and what is the correct function to use!