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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Max Date - Multiple Entries when trying to pull for a single products

All,

I have a table of data that contains a Product Code , Sales date ( date only no time) , Customer Name and Sales Qty In a QS table.  I am pulling I the last Sales date( max)   which works fine. However, as soon as I pull the customer name  ( where there could be multiple customers purchasing on the same day) I get the line replicated per customer. How can I just pull just one customer ( as an example customer) .  I know this sound strange but our Sales team just want to see a random customer for that day. I would have used Qty i.e Max Qty but this could be replicated as well on the same .

Any Ideas?

2 Replies
shiveshsingh
Master
Master

Can you share sample data?

Your expectation is to find the customer with max(date), like this?

rubenmarin

Hi Jeff, maybe using rand with the number of different customers and use this to load only one customer

LET vCustomerIndex = Ceil(Rand()*FieldValuecount('CustomerCode'));

LET vCustomerCode = FieldValue('CustomerCode', $(vCustomerIndex));

RandomCustomer:

LOAD Fields

From/Resident

Where CustomerCode='$(vCustomerCode)';