Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Set analysis aggr() expression

Hello community,

My dataset looks like:   

CustomerRowNumberBookingDateStartBookingDateEndDaysBetweenFlagSales
12315-1-201511-1-201561100
12321-2-20151-3-2015281150
123310-3-20151-4-2015221100
12341-4-20151-10-20151830100
12359-5-20151-10-20151450150
12361-6-20151-8-2015331100
123724-7-20141-6-20153120100
12381-1-20151-9-2015111150
12391-2-20151-11-2015341100

In the dashboard I want to make an expression looks like below, but it is not working well.

sum( aggr( {< Flag={1}, vMaxDate={'<BookingDateEnd'} >} Sales * (( BookingDateEnd - vMaxDate) / DaysBetween), RowNumber))

I think the part below is not working well. It looks de aggr() goes wrong.

(( BookingDateEnd - vMaxDate) / DaysBetween)

When vMaxDate = 1-6-2015

The Result I want is:

   

CustomerRowNumberBookingDateStartBookingDateEndDaysBetweenFlagSalesResult €
12315-1-20151-11-2015300110051
12321-2-20151-3-20152811500
123310-3-20151-4-20152211000
12341-4-20151-10-201518301000
12359-5-20151-10-201514501500
12361-6-20151-8-2015611100100
123724-7-20141-6-201531201000
12381-1-20151-9-2015243115056,79
12391-2-20151-11-2015273110056,04
263,83

   

CustomerResult €
123263,83

Can you help?

Regards,

Arjan

1 Solution

Accepted Solutions
sunny_talwar

This?

Capture.PNG

Expression:

=Sum(Aggr(Sum({<Flag = {1}, BookingDateEnd = {'>$(vMaxDate)'}>}Sales) * ((BookingDateEnd - vMaxDate)/(BookingDateEnd - BookingDateStart)), Customer, RowNumber))

View solution in original post

8 Replies
sunny_talwar

May be this:

=Sum({<Flag = {1}, BookingDateEnd = {'>1-6-2015'}>}Sales) * ((BookingDateEnd - '1-6-2015')/(BookingDateEnd - BookingDateStart))


Capture.PNG

sunny_talwar

Or this with the variable:

=Sum({<Flag = {1}, BookingDateEnd = {'>$(vMaxDate)'}>}Sales) * ((BookingDateEnd - vMaxDate)/(BookingDateEnd - BookingDateStart))


Capture.PNG

Anonymous
Not applicable
Author

Thanks for your answer Sunny T, but I'm missing the aggr() in the expression. When I delete the column RowNumber the expression is not working. First the expression must calculate per rownumber the result and then do a Sum()

sunny_talwar

So you only want to see the result as Customer = 123 and sales = 263.83? No break down is needed?

sunny_talwar

This?

Capture.PNG

Expression:

=Sum(Aggr(Sum({<Flag = {1}, BookingDateEnd = {'>$(vMaxDate)'}>}Sales) * ((BookingDateEnd - vMaxDate)/(BookingDateEnd - BookingDateStart)), Customer, RowNumber))

Anonymous
Not applicable
Author

For this example I only want to see the results: Customer and Sales.

swuehl
MVP
MVP

Are you sure you need the advanced aggregation? It should work if you include the days calculation into the sum:

=Sum(

{<Flag = {1}, BookingDateEnd = {'>$(vMaxDate)'}>}

Sales * ((BookingDateEnd - vMaxDate)/(BookingDateEnd - BookingDateStart))

)

sunny_talwar

You are right, I usually have difficult time determining when everything within the Sum would work and when would it not work. I guess its related to aggregation within aggregation kind of concept, right?