Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
ZimaBlue
Creator
Creator

Min doesn't work for date

Hello!

I'm just trying to find the minimum payment date for the user id in the row.

But min() doesn't work with the date and I'm not sure it works correctly at all. For some rows it shows an empty value, and for some user ids it shows a different minimum date in each row. What can I do to make it work?

I try:

date(min(date#(payment_date, 'DD.MM.YYYY')), 'DD.MM.YYYY') as min_pmntD

min(payment_date)

etc.

Different options don't work.

Date format: DD.MM.YYYY

4 Replies
hic
Former Employee
Former Employee

Do you have a "Group By" in your Load statement?

ZimaBlue
Creator
Creator
Author

Hello! Yes, my script is:

left join (final_table)
load
user_id,
min(payment_date) as min_pmntD,
amount_money
Resident pmnts

group by
user_id,
amount_money;

_____________

I separately tried to reach this through the chart formula, counting the sum for the minimum date, but this still displays random values, and not those that really correspond to the minimum date

Sum({<[payment_date]= {"$(=(Min(total <user_id> payment_date)))"}>} amount_money)

 

 

 

hic
Former Employee
Former Employee

Your script example looks perfectly OK, so there is something else that goes wrong.

It should also be possible in a chart formula (if the date has been correctly interpreted in the script). Your chart expression looks OK - but the "... total <user_id> ..." will be ignored: Dollar expansions and set expressions are not sensitive to chart positions. They are both evaluated globally, before the chart is broken down on individual rows.

ZimaBlue
Creator
Creator
Author

Thank you for your help! I couldn't figure out what the problem was, so I went and changed the original sql query to my database, adding a min() there.