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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
hakandikmen
Contributor
Contributor

Max and Group by

Hello,

 

I can't write the Script code (Load) that will provide the output below.

how can I do it? thanks.

 

hakandikmen_0-1692614495393.png

 

 

 

 

Labels (2)
1 Solution

Accepted Solutions
martinpohl
Partner - Master
Partner - Master

Hi,

you want to do this in script?

YourData:

load 

all your fields

from [lib://source];

left join load

max(CompletedDate) as MaxDate,

IssueNo

resident YourData group by IssueNo;

MaxData:

noconcatenate load * resident YourData where CompletedDate = MaxDate;

drop table YourData;

Maybe you have to check your table after left join that number format of Maxdate is correct number format of CompletedDate, if not set timestamp().

Regards

 

View solution in original post

5 Replies
martinpohl
Partner - Master
Partner - Master

Hi,

you want to do this in script?

YourData:

load 

all your fields

from [lib://source];

left join load

max(CompletedDate) as MaxDate,

IssueNo

resident YourData group by IssueNo;

MaxData:

noconcatenate load * resident YourData where CompletedDate = MaxDate;

drop table YourData;

Maybe you have to check your table after left join that number format of Maxdate is correct number format of CompletedDate, if not set timestamp().

Regards

 

Or
MVP
MVP

Have a look at using FirstSortedValue() for this. It should be exactly what you need.

 

 

md_talib
Contributor III
Contributor III

IF you wan to get the max value from the status. 

Use this

Table:

Load 

CreatedDate,

CompletedDate,

DemandOwner, 

IssueNo,

IsuueType,

Responsible,

Status,

CreatedDate&'-'&IssueNo as KEY,

from datasource;

left join 

Load 

KEY,

Status,

max(CreatedDate) as MaxTime,

resident Table

group by Status,KEY;

 

hakandikmen
Contributor
Contributor
Author

Thanks, it worked.

So how can we do this as a separate table.

Without using Left Join. Max and its data keep it in that table..

 

Can you help with this?

robert99
Specialist III
Specialist III

Use left keep