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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Find Order status for the latest Order by finding Max date for a spcific product

I am trying to display the last order status by product

I am doing it in the load statment like the following

Load

Product,

Max(OrderDate) // can i add if(max(OrderDate)=OrderDate,Status)...it is giving me error message

Resident Table1

Group by Product

1 Solution

Accepted Solutions
hector
Specialist
Specialist

Hi, are you trying of just leave the last order date in the model?, because you can do that with Set Analysis too, anyway i guess this is the code that you are looking for


Table1:
Load
Product,
OrderDate,
Status
from ......;

inner join
Load
Product,
Max(OrderDate) as OrderDate
Resident Table1
Group by Product


The "secret", is that Table2 will be a table with 2 field, Product & Max(orderdate), but giving the same name (alias) of the original field "OrderDate", this is going to "delete" all the records that are not equal to the last OrderDate

Rgds

PS. In Set Analysis, will be much simpler, it will be something like a table with the dim. Product and the expression Only({<OrderDate = {$(=Max(OrderDate))}>} Status)

View solution in original post

4 Replies
hector
Specialist
Specialist

Hi, are you trying of just leave the last order date in the model?, because you can do that with Set Analysis too, anyway i guess this is the code that you are looking for


Table1:
Load
Product,
OrderDate,
Status
from ......;

inner join
Load
Product,
Max(OrderDate) as OrderDate
Resident Table1
Group by Product


The "secret", is that Table2 will be a table with 2 field, Product & Max(orderdate), but giving the same name (alias) of the original field "OrderDate", this is going to "delete" all the records that are not equal to the last OrderDate

Rgds

PS. In Set Analysis, will be much simpler, it will be something like a table with the dim. Product and the expression Only({<OrderDate = {$(=Max(OrderDate))}>} Status)

Not applicable
Author

Thanks Hector, I will try your first suggestion.

Quick Question, will Set Analysis work in the load statment?

hector
Specialist
Specialist

Quick answer: No, set analysis is just for charts (bar, line.....pivot/straight tables) and every object that supports an expression

Rgds

Not applicable
Author

Thanks Hector, your Trick did the Job.