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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
thakkarrahul01
Creator
Creator

Min of date when flag is 1

Hi Everyone,

I am trying to calculate minimum date from a field when only for the records where corresponding flag is set to 1.

I have used expression in text box as :

=only({<RecDate={"$(=date(min(RecDate)))"},Flag={1}>}RecDate)

I am getting output as dash. Can anyone please help.

Please find data attached.

Kind Regards,

Rahul

7 Replies
MK_QSL
MVP
MVP

=Date(FirstSortedValue({<Flag = {1}>}RecDate, RecDate))

swuehl
MVP
MVP

For the minimum date, just use

=Min({<Flag={1}>} RecDate)


or formatted

=Date(Min({<Flag={1}>} RecDate))

Kushal_Chawda

You can do the same in script to make expression simpler

Data:

LOAD date(RecDate,'DD/MM/YYYY') as  RecDate,

     Flag,

     Text

FROM

[Book1.xlsx]

(ooxml, embedded labels, table is Sheet1);

Left Join

LOAD date(min(RecDate),'DD/MM/YYYY') as RecDate,

'1' as MinDateFlag

Resident Data

where Flag=1;

Now write the expression

=only({<MinDateFlag={'1'}>}RecDate)

thakkarrahul01
Creator
Creator
Author

swuehl‌ & @Manish

Perfect !!  Thanks a lot

Anonymous
Not applicable

what about this?

=IF(Flag=1, min(date))

thakkarrahul01
Creator
Creator
Author

Yes, gives a simpler expression. I am avoiding a data model change for now.

Thanks Kush141087

thakkarrahul01
Creator
Creator
Author

I tried this, It falls over and gives: 15/12/1958