Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load only last status!

Hi!

I need to load only the latest status of the same name and user code.

In short, the last line pertinent to an id.

This can be done both in the script and in an expression?

Thank You!

I have this:

Load1.png

I want this:

Load2.png

1 Solution

Accepted Solutions
maxgro
MVP
MVP

in script, assuming the last by rn (= your row field) and using peek to filter

Tmp:

load *, rowno() as rn;

LOAD * INLINE [

cod, name, status

1, j, a

5, m, a

1, j, i

1, j, a

3, c, a

3, c, i

5, m, i

1, j, i

];

Table:

NoConcatenate

load

  rn, cod, name, status

Resident Tmp

where peek(cod) <> cod or peek(name) <> name

order by cod, rn desc;

drop table Tmp;

View solution in original post

10 Replies
Not applicable
Author

Dont you have any kind of Date to define wich is the last status?

Not applicable
Author

Oh just saw the row_id....

guessing that's is incremental i would use a resident load on the script to flag the last status (so you keep the history of change status)

Not applicable
Author

Use max and group by

 

Data:

LOAD
max(Row) as Row,
COD,
NAME,
STATUS
FROM Data.xlsx
(
ooxml, embedded labels, table is Sheet1)
Group By COD,
NAME,
STATUS
;

maxgro
MVP
MVP

in script, assuming the last by rn (= your row field) and using peek to filter

Tmp:

load *, rowno() as rn;

LOAD * INLINE [

cod, name, status

1, j, a

5, m, a

1, j, i

1, j, a

3, c, a

3, c, i

5, m, i

1, j, i

];

Table:

NoConcatenate

load

  rn, cod, name, status

Resident Tmp

where peek(cod) <> cod or peek(name) <> name

order by cod, rn desc;

drop table Tmp;

MK_QSL
MVP
MVP

Make a Straight Table

Dimension = Name and Cod

Expression = FirstSortedValue(STATUS,-Row)

Make a Straight Table

Dimension = Name

Expression = Aggr(FirstSortedValue(STATUS,-Row),COD)

Make a Straight Table

Dimension = Code

Expression = Aggr(FirstSortedValue(STATUS,-Row),Name)

Hope this would help.

maxgro
MVP
MVP

and in chart

dimension           COD

                         NAME

expression          FirstSortedValue(STATUS, -ROW)

Not applicable
Author

hi

if you do this in chart --

then try this

Dimension1-

Aggr(max(Row),Name)

then

Dimension2-

COD

Dimension3-

Name

Expression-

Status

Not applicable
Author

hi

try this

Dimension1-

COD

Dimension2-

NAME

Expression

Aggr(Firstsortedvalue(Status,-Row),NAME)

Not applicable
Author

Perfect! Works great!

Thank You Massimo and all of You!