Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
PescheSwitzerland
Contributor II
Contributor II

Only show the newest date (valid from)

Hi there 🙂

I have a list of products with list prices and different valid-from dates to this prices. Now I simply want to show only the newest valid-from dates (one per product). Thats it 😄 

Coud you please help me out with the script function. Attached you find the table load.

Thanks a lot!
Pesche

Labels (2)
8 Replies
steeefan
Luminary
Luminary

Let's assume the table of which you posted the LOAD script is called Product:

 

ProductMaxDate:
NOCONCATENATE LOAD
  product_id,
  MAX([Price valid from]) AS MaxValidFrom
RESIDENT
  Product
GROUP BY
  product_id;

 

You will now have a second table, ProductMaxDate, containing each value for product_id and the corresponding highest [Price valid from] value.

PrashantSangle

Hi,

max() or firstsortedvalue() will help you

try below

test:

yourscript;

Left join

Load product_id

date(max([Price valid from]) as "Latest Price Valid From"

Resident test

Group by product_id;

 

Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
PescheSwitzerland
Contributor II
Contributor II
Author

Thanks again @steeefan - Now it shows up now the newest date in each row, but all [List Price]'s - just with the new date - what could we change that it shows up only one row with the product and the newest price? 

Thanks!

steeefan
Luminary
Luminary

If that's what you want, you can JOIN the max. date to your table and create a flag:

LEFT JOIN (Product) LOAD
  product_id,
  MAX([Price valid from]) AS [Price valid from],
  True() AS isMaxDate
RESIDENT
  Product
GROUP BY
  product_id;

You can then filter on isMaxDate, either in the script in a WHERE clause or on your dashboard.

ProductF:
NOCONCATENATE LOAD
  *
RESIDENT
  Product
WHERE
  isMaxDate;

DROP TABLE Product;

 

PescheSwitzerland
Contributor II
Contributor II
Author

Ok, then it shows up 29.12.1899 in each row 😅 what can I change to fix this? 

Thanks!

steeefan
Luminary
Luminary

That's just the date representation of the value -1, which is the value of the newly introduced flag isMaxDate.

steeefan_0-1715606408682.png

 

PescheSwitzerland
Contributor II
Contributor II
Author

Ah ok, I got it, of course. And how can I show the date itself? 🙂 Thanks for all your help! 😊

steeefan
Luminary
Luminary

You simply need to show the values of [Price valid from] where isMaxDate=-1, either by filtering in the script with a WHERE clause or on your dashboard (Set Analysis, selections).