4 Replies Latest reply: Dec 12, 2016 1:28 PM by Jarkko Pelli

# Firstsortedvalue and sum

Hi,

I have a very simple issue I cant figure out. I have 2 columns, A column with value and B column vith Date. Im using firstsorteddate to get the latest enrty from those 2 columns.

firstSortedValue(Valuation,-[date([Effective date]])])

This is working, if the expression only returns one latest date. But when there are 2 latest dates, it does not return anything. How do I sum the valuation when there are multiple entries?

Thanks for your help!

• ###### Re: Firstsortedvalue and sum

May be this:

FirstSortedValue(Aggr(Sum(Valuation), [date([Effective date]])]), -Aggr([date([Effective date]])], [date([Effective date]])]))

• ###### Re: Firstsortedvalue and sum

You are a star Sunny, thanks!

It works great, only one minor issue remains. Im using this in a pivot table as a measure, and I have multiple rows as companies. This expression works great, when I select an individual line (company as a filter), the value is correct. When I select 5 companies, It calculates the value of all of those 5 companies to the top rows column, and leaves the rest empty

Company 1   5000€

Company 2   -

Company 3   -

Company 4   -

Company 5   -

Is this somehow possible to fix?

• ###### Re: Firstsortedvalue and sum

See if this works:

FirstSortedValue(Aggr(Sum(Valuation), [date([Effective date]])], Company), -Aggr([date([Effective date]])],[date([Effective date]])], Company))

• ###### Re: Firstsortedvalue and sum

Thanks Sunny, works like a charm!