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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

min/max date

Hi everyone,

I need to get the min and max value from a date field. The date is in YYYY-MM-DD format.

Thanks!

8 Replies
prieper
Master II
Master II

Use the MIN- or MAX-function:

LOAD MIN(MyDate) AS MinDate, MAX(MyDate) AS MaxDate FROM ....


HTH
Peter

Not applicable
Author

For some reason those functions do not work. When I reload the script an eror message saying "Invalid expression" is displayed.

Not applicable
Author

Hi

Please post your script so we can take a look.

/Fredrik

Not applicable
Author

perhaps your date is in string then try using the makedate function

or use date(min(date#(MyDate))) as MinDate

Not applicable
Author


LOAD



Number,
Date,
min(Date) as MinDate
FROM
C:\Users\operator_bi\Desktop\proj\invoices\globul_invoice_2008_11_01.xls
(
biff, embedded labels, table is details_1$);




Not applicable
Author

I have similiar problem. I wrote the following code :

LOAD CustomerName, Date, Value, min(Date) as MinDate

FROM
C:\Users\operator_bi\Desktop\proj\invoices\globul_invoice_2008_11_01.xls
(biff, embedded labels, table is details_1$)

GROUP BY CustomerName

and i get "Invalid expression". I tryed every option with date formating. I read several other post, but no result. So if you know anything, I will be glad.

Not applicable
Author

Hi

When you use an aggregation function, like min, max, avg etc. you must use a group by clause and specify all other fields that aren't being aggregated.
For instance, if you want to do this:

LOAD
A,
B,
max(C) as C

you must have a group by clause like this:

group by A, B

This should work for you:
LOAD
Number,
min(Date) as MinDate
FROM C:\Users\operator_bi\Desktop\proj\invoices\globul_invoice_2008_11_01.xls (biff, embedded labels, table is details_1$)
GROUP BY Number;

Refer to the helpfile and look for Aggregation functions to get some examples.

/Fredrik

Not applicable
Author

Do this

LOAD CustomerName,

Date,

Value,

min(Date) as MinDate

FROM
C:\Users\operator_bi\Desktop\proj\invoices\globul_invoice_2008_11_01.xls
(biff, embedded labels, table is details_1$)

GROUP BY CustomerName,Date,Value;