Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Aggregation based on maximum value of record

Hi all,
I'm struggeling with this for a few days now so I hope one of you can help me out here.
I have a table like this:
IDCodeSort
1R
1V1
2R
2E12
3R
3E22
3V1
4R
4E22
4B3
And I would like to have a chart in the front end counting the number of ID's by Code with only the records counted with the lowest sort value. So the result should be:
CodeCount
V2
E11
E21
B0
R0
I've been using the firstsortvalue() function but as soon as I add Code as a dimension it doesn't work anymore.
All help is welcome!
Erik
1 Solution

Accepted Solutions
RedSky001
Partner - Creator III
Partner - Creator III

Create a calculated dimension

=AGGR(if(Sort = Min(TOTAL <ID>Sort),Code),ID,Code)

then an expression:

count(ID)

B & R won't appear if the related sort values are nulls...

View solution in original post

4 Replies
RedSky001
Partner - Creator III
Partner - Creator III

How did you get a count of 1 for code E2, when the sort value is 2 for both rows?  I would of thought the count should be 2... I'm confused (doesn't take much)

Not applicable
Author

Because the E2 for ID 3 has a sort value of 2 while V (of ID 3) has a sort value of 1. So only the smallest sort value should be counted.

RedSky001
Partner - Creator III
Partner - Creator III

Create a calculated dimension

=AGGR(if(Sort = Min(TOTAL <ID>Sort),Code),ID,Code)

then an expression:

count(ID)

B & R won't appear if the related sort values are nulls...

Not applicable
Author

That's it!

Thanks a lot for your help

Erik