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: 
Not applicable

Sum of the purchases of 1st tickets of the customers

Hi

I Need to calculate : Sum of the purchases of 1st tickets of the customers, sorted out by 1st week of purchase
I write the dimension with no problem at all : =week(aggr(min([Date ticket]),[Code conso]))

for the indicator I make the test :
=sum({<[Date ticket]={"=aggr(min([Date ticket]),[Code conso])"}>}[CA])

But for certain customers the result is false .

the Data is

Consumer
  ID
Ticket Dateligne ticket IDTicket IDPRODUCTAmountQuantity
35778906/12/20142811511708748814393081_01_19/22111
35778906/12/20142811511718748814318021_01_12M451
35778906/12/20142811511728748814330121_01_12M691
35778906/12/20142811511738748814390141_01_46251
35778930/05/20152982528899212416925002_45_2A25,21
35778930/05/20152982528909212416910022_77_2A211


I want the sum of amount of the 1rst ticket (06/12/2014) of the consumer 357789 : 150

Any other idea?

I put in attached files an example of application and the expected result(profit)

thanks


1 Solution

Accepted Solutions
rubenmarin

And now tested in your qvw, for all customers, can you try?:

Sum(Aggr(If([Ticket ID]=Min(TOTAL <[Consumer ID]> [Ticket ID]), Sum(Amount)), [Consumer ID], [Ticket ID]))

View solution in original post

3 Replies
rubenmarin

Hi Magali, can you try?;

For one customer: FirstSortedValue(Sum(Amount), [Ticket ID])

For all customers: Sum(Aggr(FirstSortedValue(Sum(Amount), [Ticket ID]), [Consumer ID]))

rubenmarin

And now tested in your qvw, for all customers, can you try?:

Sum(Aggr(If([Ticket ID]=Min(TOTAL <[Consumer ID]> [Ticket ID]), Sum(Amount)), [Consumer ID], [Ticket ID]))

Not applicable
Author


thanks a lot for your help Ruben.

My answers :

For one customer: FirstSortedValue(Sum(Amount), [Ticket ID]) => error in expression

For all customers: Sum(Aggr(FirstSortedValue(Sum(Amount), [Ticket ID]), [Consumer ID]))  => 0

and the third is OK !

Sum(Aggr(If([Ticket ID]=Min(TOTAL <[Consumer ID]> [Ticket ID]), Sum(Amount)), [Consumer ID], [Ticket ID]))

I understood your expression. I do not know well the Aggregation functions  but thanks to you I progressed a lot today. Thank you very much