Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Qlik Community,
i have got a question regarding sales of min and max month for each customer.
I want to show the the sales of the minimum month and the maximum month in a table. i Created some sample data
Customer | Date | Sales |
A | 01.01.2015 | 374 |
A | 01.02.2015 | 121 |
A | 01.03.2015 | 318 |
A | 01.04.2015 | 400 |
B | 01.02.2015 | 179 |
B | 01.03.2015 | 440 |
B | 01.04.2015 | 349 |
C | 01.01.2015 | 332 |
C | 01.02.2015 | 496 |
C | 01.03.2015 | 107 |
D | 01.02.2015 | 121 |
D | 01.03.2015 | 183 |
E | 01.03.2015 | 222 |
So for Customer A Min Month is January and Max month is April.
For Customer B Min Month is February and Max month is April
And so on.
I used the following expression in QlikView
sum(if(MonatId=aggr(min(MonatId),Customer),Sales))
It seems to work for minimum values, but for maximim values it shows only the sales of Customer E. Any idea why?
The result i would expect would be
Customer | Min Month Sales | Max Month Sales |
---|---|---|
A | 374 | 400 |
B | 179 | 349 |
C | 332 | 107 |
D | 121 | 183 |
E | 222 | 222 |
I attached a sample file.
I really could use some help 🙂
Regards from Germany,
Fabian
Min
FirstSortedValue(Aggr(SUM(Sales),Customer,Monat),Monat)
Max
FirstSortedValue(Aggr(SUM(Sales),Customer,Monat),-Monat)
Min
FirstSortedValue(Aggr(SUM(Sales),Customer,Monat),Monat)
Max
FirstSortedValue(Aggr(SUM(Sales),Customer,Monat),-Monat)
Try with FirstSortedValue function
PFA
It works! Thanks!