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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register 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....

18 Replies
Not applicable
Author

As Poojananda told:

Header4 has two values a1 and a2. a1 takes priority.whenever a1 availabe

need to ignore a2 records.

The only question is If there arr only 2 priority values. If YES, there may

be If or pick be used. But If priority has more possible values, we need

more dynamic approach.

04-04-2014 09:31 użytkownik "Sunil Kumar" <qcwebmaster@qlik.com>

napisał:

Qlik Community <http://community.qlik.com/> Finding max

reply from Sunil Kumar<http://community.qlik.com/people/sunilkumarqv?et=watches.email.thread>in *New

to QlikView* - View the full discussion<http://community.qlik.com/message/502205?et=watches.email.thread#502205>

Not applicable
Author

I just found very nice solution!

1. Lets assume for a moment, that we load additional integer column (i named it "priority"). It has values corresponding to header 4, but without letter a. So, it has values 1 for a1, 2 for a2, etc.

2. Lets assume, that we are able during reload create expression body like this (and for exaple put it into variable value).:

pick(min(priority), max({<priority={1}>}[Header 5]),max({<priority={2}>}[Header 5]),max({<priority={3}>}[Header 5]),....max({<priority={n}>}[Header 5]) )

(I have no time to prepare load script which will build this expression, but it is not difficult)

in my case expression is:

pick(min(priority), max({<priority={1}>}[Header 5]),max({<priority={2}>}[Header 5]),max({<priority={3}>}[Header 5])),

because in my tests max priority in all popullation has value 3.

3. If we have above done, solution is easy and, should has normal performance.

Take a look on last column in chart.

Have fun with QV

regards

Darek

Not applicable
Author

Thank you so much.It seems working.Can you please explain me the expression code.

Not applicable
Author

Hey all thank you so much for all these ideas.You guys rock!

Not applicable
Author

Priority has only two values,a1 and a2.no third value for that column.

Not applicable
Author

Hi Sunil-a1 has only two values 10 and 11 in the above example.a1 takes priority over a2.so need to ignore the record where header5 is 40.

Not applicable
Author

I donot think I can go with this option.Because header3 has multiple values,cannot hardcod with
If([Header 3]='T1' or If([Header 3]='T2'.Only header4 has two static values a1 and a2.Sorry may be I was not clearly mentioned this in the requirements.

Not applicable
Author

Please take expression from comm_header1_5_v3.qvw  I attached in one of my responses.

1. column with Header4 is Calculated Dimension:

=aggr(minstring([Header 4]),[Header 1],[Header 2],[Header 3])

So, i simple gives you minimal valye of H4 for combination of H1,H2,H3

2. Header 5 column:

pick(min(priority), max({<priority={1}>}[Header 5]),max({<priority={2}>}[Header 5]),max({<priority={3}>}[Header 5]))

a)

pick(n,ex1,ex2,ex3,...,exm)

n-integer value, in our case n=min(priority)

pick() gives you n'th expression. So, if our priority = 2, there will be ex2

our expression are very similiar to each other:

max({<priority={1}>}[Header 5]) is taken when priority =1

max({<priority={2}>}[Header 5]) is taken when priority =2,

.......

Belive me, even if today you have only 2 priorities, there may be someday 3-rd priority So, be ready for it

If you need some more information, please let me know.

regards

Darek

Not applicable
Author

Darek..Thank you so much for your time to explain the code.Have a great day.