Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculating the SUM based on MAX(Date)

Hi All,

I have following data -

ProductLocationDateSales
AZ01-01-2013100
AZ01-01-2013100
AZ31-11-2012200
BY12-12-2012300

1. I want to identify MAX(Date) group by location id.

2. Then calculate the SUM(Sales) based on MAX(Date) returned by step 1.

The result should be as follows -

ProductSales
A200Since 01-01-2013 is the max date in location Z
B300

Please help me how I can achieve this in straight table.

Regards,

Samir Prasadi.

9 Replies
thomduvi83
Partner - Contributor III
Partner - Contributor III

You can try this as expression in your table :

Sum(aggr(

          FirstSortedValue(aggr(

                         Sum(Sales)

          ,Product,Location,Date),-Date)

,Product))

Br.

Not applicable
Author

Hi,

This is not working inmy application.

Regards,

Samir

CELAMBARASAN
Partner - Champion
Partner - Champion

Are you expecting this in load script or charts?

Not applicable
Author

In the Chart.

Not applicable
Author

I tried the following expression in the chart expression -

SUM(

          IF(

               AGGR(MAX(DATE)), LOCATION) = DATE, SALES

              )

)

but this does not work ..

CELAMBARASAN
Partner - Champion
Partner - Champion

Can you upload a sample file that you are working with?

Not applicable
Author

I have attached a sample app.

Regards,

Samir

CELAMBARASAN
Partner - Champion
Partner - Champion

Please check the attached file

Not applicable
Author

Hi,

Thanks for your response. This is working fine on the test file but the logic is not working on my production dashboard. Is there any other way to get solution for this scenario ?

Regards,

Samir.