Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Mahamed_Qlik
Specialist
Specialist

Chart expression

Hi

We want to calculate count of each distinct Parcle number whoes order date is max for.

mahamedfaijan_2-1650726635549.png

 

In above table the Total count should be 3.
In bar chart dimension will be Product name and measure should be count ( distinct Parcel number)

Kindly advise

Labels (1)
4 Replies
rubenmarin

Hi, if possible t would be easier and give better performance if you add a flag to the max record in script, just do a sorted load by [PArcel Number] and [Order Date] desc, and use peek() to set the flag to 1 when [Parcel Number]<>Peek([Parcel Number])

With this the expression could be a simple: Sum(flagField)

Without it you can use aggr() like:

Sum(Aggr(If([Order Date]=Max(TOTAL <[Parcel Number]> [Order Date]),1,0),[Parcel Number],[Product Name]))

Mahamed_Qlik
Specialist
Specialist
Author

Hi Rub,

Thanks for the response but below expression is not returning the result.
Sum(Aggr(If([Order Date]=Max(TOTAL <[Parcel Number]> [Order Date]),1,0),[Parcel Number],[Product Name]))

 

vinieme12
Champion III
Champion III

Just Use a Calculated dimension for OrderDate

= if(OrderDate = aggr(Max(OrderDate),ParcelNumber),OrderDate,null()). <--- uncheck show null values for this dimension

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
rubenmarin

Hi, I did a test and it worked for me, in table and in KPI.

You can upload a sample to check what is different.