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

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!

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar

See if this works:

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

View solution in original post

4 Replies
sunny_talwar

May be this:

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

Anonymous
Not applicable
Author

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?

sunny_talwar

See if this works:

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

Anonymous
Not applicable
Author

Thanks Sunny, works like a charm!