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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Finding max

Can someone please help with this.

This is the source data in the table

Header 1Header 2Header 3Header 4Header 5
Alex1/1/2013T1a110
Alex1/1/2013T1a111
Alex1/1/2013T1a230
Alex1/1/2013T1a240
Alex1/1/2013T2a210
Alex1/1/2013T2a213
Alex1/1/2013T2a215

Header4 has two values a1 and a2.

a1 takes priority.whenever a1 availabe need to ignore a2 records.

objective is to find max(header5).

so the final result would be

Header 1Header 2Header 3Header 4Header 5
Alex1/1/2013T1a111
Alex1/1/2013T2a215

Thanks....

1 Solution

Accepted Solutions
Not applicable
Author

Anyway ..... i hope you like it .

Have fun with QV:)

regards

Darek

View solution in original post

18 Replies
maxgro
MVP
MVP

RESULT

1.png

SCRIPT

DIRECTORY;

s:

LOAD [Header 1],

    [Header 2],

    [Header 3],

    [Header 4],

    [Header 5]

FROM

[http://community.qlik.com/thread/113110]

(html, codepage is 1252, embedded labels, table is @1);

t:

load * where key<>peek(key);

NoConcatenate

load

rowno() as id,

[Header 1] & '-' & [Header 3] as key,

*

Resident s

order by [Header 1], [Header 3], [Header 4], [Header 5] desc;

DROP Table s;

Not applicable
Author

Anyway ..... i hope you like it .

Have fun with QV:)

regards

Darek

arjunkrishnan
Partner - Creator II
Partner - Creator II

Regards

Not applicable
Author

Arjun,

as my license finished please show Header 5 expression. I'am interested if you have found another way than I to resolve it.

regards

Darek

arjunkrishnan
Partner - Creator II
Partner - Creator II

Hai Darek

If([Header 3]='T1' and [Header 4]='a1',aggr(Max([Header 5]),[Header 4]),

If([Header 3]='T2',aggr(Max([Header 5]),[Header 3])))

Not applicable
Author

Hi  DARIUSZ MIELCZAREK

in ur Demo U Just Add These steps

A:

LOAD [Header 1],

     [Header 2],

     [Header 3],

     [Header 4],

     [Header 5]

FROM

max.xls

(biff, embedded labels, table is [Sheet1$]);

B:

LOAD * Where key<> Peek(Key);

load *,

[Header 1] & '-' & [Header 3] as key,

Resident A

order by [Header 1], [Header 3], [Header 4], [Header 5] desc;

DROP Table A;

in table chart give header 1,2,3,5 as dimensions  and Expression is ur  =Aggr(MinString([Header 4]),[Header 1],[Header 2], [Header 3]) expression..

try this ..................

Not applicable
Author

Hey check this..!!sol.pngsol2.png

Not applicable
Author

Amay,

your expression finds max, but over Heder3.

As i understand, Pojananda wants to:

1. Aggregate Header 4 over Heder1-3.

2. find max Heder 5 for Header4 callculated in step 1.

My solution calculates exactly this. Even if we will have more tahn 2 values to consider in Heder 4. So it is dynamic approach. I;am also afraid that my method may has poor performance. This is why i'am interested if somebody has some another idea.

@Arjun - i'am afraid, that your expression will not work if we will load some different data into Heder3 or Header4

reagards

Darek

sunilkumarqv
Specialist II
Specialist II

@your main objective is to find max Header 5 you probably written wrong out put

so the final result would be like these not 11 .

Header 1Header 2Header 3Header 4Header 5
Alex1/1/2013T1a140
Alex1/1/2013T2a215

for best results find attached