Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
samp
Contributor III
Contributor III

Display single value in Text Box using Min and Max functions

Can you help on to get only below required comment to display in "Text and Image" box in QS based on Max(Flag )  and Min(Date).

Load * Inline [
Flag,Date,Comment
0,'01/01/2019',comment1
0,'01/02/2019',comment2
0,'01/03/2019',comment3
1,'01/04/2019',comment4
1,'01/05/2019',comment5
1,'01/06/2019',comment6
1,'01/07/2019',comment7

];

date format: MM/DD/YYYY

Expected result:

comment4

Trying with : 

Only({< Date = {"$(=Min(Date))"},Flag={1} >} Comment)

Thanks for your quick help.

 

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar

May be this

Only({<Date = {"$(=Date(Min({<Flag={1}>}Date), 'MM/DD/YYYY'))"}, Flag={1}>} Comment)

 

View solution in original post

7 Replies
Vegar
MVP
MVP

Try

Only({< Date = {'$(=MinString(Date))'},Flag={1} >} Comment)

samp
Contributor III
Contributor III
Author

Hi,

not working if we have 2 conditions.

But ok for 1 condition.

Only({< Date = {'$(=MinString(Date))'} >} Comment)

Vegar
MVP
MVP

I understand, but max(date) min(flag) can be intepreted in at least three ways.

  • "The minimum day for the maximum flag" -> Comment4

=only({<
Flag = {$(=max(Flag))},
Date = {'$(=minstring({<Flag = {$(=max(Flag))}>}Date))'}
>} Comment)

 

  • "The maximum flag for the minimum day" -> Comment1

=only({<
Flag = {$(=max({<Date = {'$(=minstring(Date))'}>}Flag))},
Date = {'$(=minstring(Date))'}
>} Comment)

  • "The maximum flag and the minimum date." -> No hit in the data below

=Only({<
Comment = P({<Flag={'$(=max(Flag))'},Date={'$(=MinString(Date))'}>})
>} Comment)

 

Using this data:

Load * Inline [
Flag,Date,Comment
0,'01/01/2019',comment1
0,'01/02/2019',comment2
0,'01/03/2019',comment3
1,'01/04/2019',comment4
1,'01/05/2019',comment5
1,'01/06/2019',comment6
1,'01/07/2019',comment7

];

samp
Contributor III
Contributor III
Author

Other way, it should look for min date and flag=1

Vegar
MVP
MVP

In your example minimum date is '01/01/2019' and combined with flag=1 you wont get any hits. So the expression will return null().

 

Which comment number are you expecting from your data set?

sunny_talwar

May be this

Only({<Date = {"$(=Date(Min({<Flag={1}>}Date), 'MM/DD/YYYY'))"}, Flag={1}>} Comment)

 

samp
Contributor III
Contributor III
Author

Thanks Sunny, its working like charm.