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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Use of only function with 'Max' in set expression

I have the following data tables:

Data:

LOAD * INLINE [

EventID, Status, Value

52, A, 10

53, E, 20

54, A, 30

];

Temp:

LOAD * INLINE [

ID, EventID

37, 52

37, 53

41, 54

41, 55

41, 56

41, 57

];

Requirement:

In straight table I have to display two columns 'ID' and 'Status'. There should be single row for each ID; meaning here, there should be distinct ID's in straight table. If there are multiple values for same ID, then it's 'Status' value in our straight table column should be of max of 'EventID'.

My Expression in straight table is :

if(count(DISTINCT [Status])>1,Only({<[EventID]={$(=max([EventID]))}>}[Status]),[Status])

For example:

The output I'm expecting in Straight table is : 

ID      Status

37          E

41          A


But its giving below output:

ID      Status

37          -

41          A


'E' is expected in status column instead of null i.e.' - '.


I'm not getting the correct output. I used 'Aggr' function with max, but did'nt work. Also to mention, use of maxstring function is not expected here. I want help for this issue.

Can you suggest expression similar to this.


1 Solution

Accepted Solutions
tresesco
MVP
MVP

A distinct would be required. Try like:

=FirstSortedValue({<[Patient Status]={'*'}>} Distinct [Patient Status], -[SS_Event_EP_ID])

View solution in original post

5 Replies
jagan
Partner - Champion III
Partner - Champion III

Hi,

Why there is no status for 55, 56 and 57?  if there are values for that then use

=FirstSortedValue(Status, -EventID)

Regards,

Jagan.

tresesco
MVP
MVP

And if you have to take nulls into consideration and avoid it, try like:

FirstSortedValue({<Status={'*'}>}Status,-EventID)

PFA

Not applicable
Author

Hi All,

The expression suggested by you is not working for me.

For ID '37', its still displaying '-' instead of 'E' value in 'Status' column. !

tresesco
MVP
MVP

A distinct would be required. Try like:

=FirstSortedValue({<[Patient Status]={'*'}>} Distinct [Patient Status], -[SS_Event_EP_ID])

Not applicable
Author

Thanks, It worked.

I appreciate your help!!