Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
INPUT | ||
ACCOUNT | VALUE | DESC |
20838310 | 8999 | ABC |
20838310 | 8999 | ABC |
20838330 | 15166 | XYZ |
20838330 | 2869 | XYZ |
20838330 | 1979 | XYZ |
20838330 | 1475 | XYZ |
20838330 | 0 | XYZ |
20838331 | 16186 | ELM |
20838331 | 0 | ELM |
20838357 | 15095 | GHS |
20838357 | 15095 | GHS |
20838357 | 15095 | GHS |
20838357 | 5399 | GHS |
20838389 | 15095 | RTF |
20838389 | 7214 | RTF |
20838389 | 1997 | RTF |
RESULT | ||
ACCOUNT | VALUE | DESC |
20838310 | 8999 | ABC |
20838330 | 15166 | XYZ |
20838331 | 16186 | ELM |
20838357 | 15095 | GHS |
20838389 | 15095 | RTF |
How do I do this in the load script?
I was a bit confused about you specifying "first record" as the records appear to be duplicates. If they are different in some other field please show a sample. For now, how about:
Data:
LOAD
INPUT as ACCOUNT,
F2 as VALUE,
F3 as DESC
FROM
[https://community.qlik.com/t5/New-to-QlikView/Load-record-with-MAX-VALUE-by-Account-If-Account-has-t...]
(html, utf8, embedded labels, table is @1)
Where RecNo() > 1
;
Inner Join(Data)
LOAD Distinct
max(VALUE) as VALUE,
ACCOUNT
Resident Data
Group By ACCOUNT
;
-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com
Thanks @rwunderlich
I have used the following code and it worked for getting the record with MAX(VALUE) and it worked
DATA:
LOAD
ACCOUNT,
VALUE,
DESC
FROM ...;
right join (DATA)
load
ACCOUNT,
MAX(VALUE) as VALUE
resident DATA
group by ACCOUNT;
right join(DATA)
load
ACCOUNT,
VALUE,
FirstValue(DESC) as DESC
Resident DATA
group by ACCOUNT, VALUE;
It is not always duplicates, these are Accounts and each account could have multiple models attached to them. I need to convert multiple rows into one row for each account. Ideally I need to get to this.
Ex:
ACCOUNT | VALUE | DESC |
20318800 | 16350 | MTGHS26 |
20318800 | 0 | DGHS52HD |
20318900 | 8086 | WSR42FX600E |
20319000 | 5917 | TRENCHER |
20319100 | 0 | BAGGER |
20319100 | 18068.51 | SCWSVR36A600FX |
20319100 | 0 | SCWSCZ52V730FX |
20319200 | 6465.81 | 994106 |
20319300 | 10529.44 | EV85222 |
20319300 | 0 | A2010ICK4CUSG |
20319400 | 13375 | STT61V750KA |
20319500 | 14231 | 930875 |
20319600 | 3268.85 | 933007 |
20319700 | 6780.99 | SWZ52V-20FS |
20319800 | 26265.97 | VTX740EKC604 |
ACCOUNT | VALUE | DESC | Count | VALUE2 | DESC2 | VALUE3 | DESC3 | VALUE4 | DESC4 | VALUE5 | DESC5 |
20318800 | 16350 | MTGHS26 | 2 | 0 | DGHS52HD | ||||||
20318900 | 8086 | WSR42FX600E | 2 | 5917 | TRENCHER | ||||||
20319100 | 0 | BAGGER | 3 | 18068.51 | SCWSVR36A600FX | 0 | SCWSCZ52V730FX | ||||
20319200 | 6465.81 | 994106 | 1 | ||||||||
20319300 | 10529.44 | EV85222 | 2 | 0 | A2010ICK4CUSG | ||||||
20319400 | 13375 | STT61V750KA | 1 | ||||||||
20319500 | 14231 | 930875 | 1 | ||||||||
20319600 | 3268.85 | 933007 | 1 | ||||||||
20319700 | 6780.99 | SWZ52V-20FS | 1 | ||||||||
20319800 | 26265.97 | VTX740EKC604 | 5 | 0 | VTX740EKC604 | 0 | VTX740EKC604 | 0 | VTX740EKC604 | 0 | ECKA30 |
Model with MAX(VALUE) will be the primary MODEL and need to flag that as PRIMARY MODEL, may be separate column.
Models at account level would always be less than 10