Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
alinesobrinho
Contributor
Contributor

help with first sorted value

Hi guys,

I need to sum the values Qty considering the period, so my dataset is like this:

Product Date Qty KEY Sum Aggr
1 01/12/2021 93 1|10|20|Text 0 0
1 01/11/2021 93 1|10|20|Text 0 0
1 01/08/2021 279 1|10|20|Text 465 279
2 01/09/2020 93 2|10|20|Text2 0 93
my sum measure is:

sum(aggr(Sum({$<[Date]={"$(='>=' & AddMonths(MonthStart(max([Date])),-11)& ' <= ' & Date(Max([Date]), 'DD/MM/YYYY'))"}>} Qty),[Key]))

my aggr measure is:

=sum(aggr(FirstSortedValue(Qty ,-aggr(max(Date),[Key])),[Key]))

This return null
=FirstSortedValue({<[Date]={"$(='>=' & AddMonths(MonthStart(max([Date])),-11)& ' <= ' & Date(Max([Date]), 'DD/MM/YYYY'))"}>}
Aggr(Sum({<[Date]={"$(='>=' & AddMonths(MonthStart(max([Date])),-11)& ' <= ' & Date(Max([Date]), 'DD/MM/YYYY'))"}>}Qty),[%SK_PriceCheck]),
Aggr(Only({<[Date]={"$(='>=' & AddMonths(MonthStart(max([Date])),-11)& ' <= ' & Date(Max([Date]), 'DD/MM/YYYY'))"}>}[Key]), [Key]))

The expected result is

Product KEY Sum
1 1|10|20|Text 465
2 2|10|20|Text2 93

Please, can someone help me?

thank you

Labels (4)
0 Replies