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

How do include ALL dimension values even if they are null in Aggr?

I am calculating the total budgeted hours for each person per month. In the statement below,

Sum(Aggr( If(Sum([Estimate Hours]) < 120, 1, 0), Resource, Month))

I'm counting the number of months where each resource had < 120 hours budgeted. This works fine for the months in which there is a forecast but ignores the months in which there is no forecast.

So, for example, if Month has values 1,2,3,4,5,6 defined and Joe has the following allocation (month, hours)

1, 100

2, 80

3, 160

then the result will be 2. It should be 5, because there was no forecast for months 4, 5, and 6.

How can I achieve this without adding a zero allocation for the missing months? I already have a table that defines all the months.

Thanks!

1 Solution

Accepted Solutions
lblumenfeld
Partner Ambassador
Partner Ambassador
Author

I tried that and it gave the incorrect count. I was able to figure it out. The expression below works.

Count(DISTINCT TOTAL Month) - Alt(Sum(Aggr( If(Sum([Estimated Hours]) >= 120, 1, 0), Resource, Month)), 0)

View solution in original post

4 Replies
swuehl
MVP
MVP

Try maybe

Sum( 6- Aggr( If(Sum([Estimate Hours]) >= 120, 1, 0), Resource, Month))


Sum( Aggr(Count(DISTINCT TOTAL Month)- Sum( Aggr( If(Sum([Estimated Hours]) >= 120, 1, 0), Resource, Month)), Resource))

lblumenfeld
Partner Ambassador
Partner Ambassador
Author

I tried that and it gave the incorrect count. I was able to figure it out. The expression below works.

Count(DISTINCT TOTAL Month) - Alt(Sum(Aggr( If(Sum([Estimated Hours]) >= 120, 1, 0), Resource, Month)), 0)

prabhu0505
Specialist
Specialist

Try this..

Sum(Aggr( If(Sum([Estimate Hours]) < 120, 1, 0)+NullCount(Sum([Estimate Hours])), Resource, Month))

swuehl
MVP
MVP

Have you tried my first or second solution?

The first will not work, but the second should. And the second should also give a total value across all Resources (e.g. when used in a text box), while I think your solution will only work on the Resource's  dimension line or when you select a single Resource.

Can you show a sample where my second solution returns incorrect values?