Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
jeckstein
Partner - Creator
Partner - Creator

Set Analysis Max Report Year where report year is not null

I have a table like this.

IDYearAmount
AAA2012300
AAA2013400
AAA2014500
BBB201250
BBB201360
CCC20121

I am looking for set analysis that will sum Amount where year is max. I am currently using this calculation in a KPI object.

Sum({$<[Year]={'$(=Max([Year]))'}>}[Amount])

The result is 500. This is because the Max(Year) for the entire group being summed is 2014 and there is no data for 2014 for ID "BBB" and "CCC"

I need the result of 561

AAA    2014     500

BBB    2013     60

CCC   2012     1

What is the set analysis i need.

3 Replies
sunny_talwar

May be use this:

FirstSortedValue(Amount, -Year)

or this in a text box object

Sum(Aggr(FirstSortedValue(Amount, -Year), ID))

UPDATE: Added a missed parenthesis at the end

sunny_talwar

Sample attached for your data

Capture.PNG

sunny_talwar

If for some reason you have multiple entries for each ID each year, you can try this:

=Sum(Aggr(FirstSortedValue(Aggr(Sum(Amount), ID, Year), -Aggr(Year, ID, Year)), ID))