Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
UncleRiotous
Creator
Creator

Unexpected Null returned in table when using Aggr(Sum on multiple lines

I'm trying to get a sub-total into a field in table but when I use Aggr I'm only getting one response back, subsequent rows are returning nulls.

Example data is 

UserTypeValue
1A2
1A3
1B5
1B4
1B1
2A15
2A4
2A9
2B1
2B4

 

My expectation is that

=Aggr(Sum(Value),User)

should return what I want but what I get is the below (the Required field is what I'm hoping to get). 

UserTypeSum(Value)RequiredAggr(Sum(Value),User)
1A515-
1A101515
2B2530-
2B53030

Weirdly if I make the final column a Measure rather than a Dimension I get the first value rather than the second. What I need is to get the same result against all the rows with the same user.

The aim is to then use =Sum(Value)/Aggr(Sum(Value),User) to get the percentage of each type for each user.

1 Solution

Accepted Solutions
stevejoyce
Specialist II
Specialist II

To repeat aggr results, use nodistinct:  =Aggr(NODISTINCT Sum(Value),User).

If User & Type are your dimensions in the object and the percent can be a measure (you mentioned something about it being a dimension?) I would do Sum(Total <User> Value).

View solution in original post

2 Replies
stevejoyce
Specialist II
Specialist II

To repeat aggr results, use nodistinct:  =Aggr(NODISTINCT Sum(Value),User).

If User & Type are your dimensions in the object and the percent can be a measure (you mentioned something about it being a dimension?) I would do Sum(Total <User> Value).

UncleRiotous
Creator
Creator
Author

Thanks Steve. NODISTINCT works perfectly.

I tried my original version as both a dimension and a measure out of desperation and all it did was move the result from the first to last record.