Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Can someone please help with this.
This is the source data in the table
Header 1 | Header 2 | Header 3 | Header 4 | Header 5 |
---|---|---|---|---|
Alex | 1/1/2013 | T1 | a1 | 10 |
Alex | 1/1/2013 | T1 | a1 | 11 |
Alex | 1/1/2013 | T1 | a2 | 30 |
Alex | 1/1/2013 | T1 | a2 | 40 |
Alex | 1/1/2013 | T2 | a2 | 10 |
Alex | 1/1/2013 | T2 | a2 | 13 |
Alex | 1/1/2013 | T2 | a2 | 15 |
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 1 | Header 2 | Header 3 | Header 4 | Header 5 |
---|---|---|---|---|
Alex | 1/1/2013 | T1 | a1 | 11 |
Alex | 1/1/2013 | T2 | a2 | 15 |
Thanks....
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>
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
Thank you so much.It seems working.Can you please explain me the expression code.
Hey all thank you so much for all these ideas.You guys rock!
Priority has only two values,a1 and a2.no third value for that column.
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.
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.
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
Darek..Thank you so much for your time to explain the code.Have a great day.