3 Replies Latest reply: May 8, 2015 2:41 AM by Fabian Heidenstecker

# Sales of minimum and maximum month

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
A374400
B179349
C332107
D121183
E222222

I attached a sample file.

I really could use some help :-)

Regards from Germany,

Fabian

• ###### Re: Sales of minimum and maximum month

Min

FirstSortedValue(Aggr(SUM(Sales),Customer,Monat),Monat)

Max

FirstSortedValue(Aggr(SUM(Sales),Customer,Monat),-Monat)

• ###### Re: Sales of minimum and maximum month

It works! Thanks!

• ###### Re: Sales of minimum and maximum month

Try with FirstSortedValue function

PFA