Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Agrr on Peek

Hi Everyone,

I have a following table

A     B

1     a

1     b

1     c

2     a

2     b

3     a

and I want a following output

A     B     Flag

1     a     -

1     b     -

1     c     1

2     a     -

2     b     1

3     a     1

Please can someone help me in getting the above output.

Thanking everyone in anticipation

Regards

Karunpreet

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Yes, a short explanation how the flag is defined would be more than helpful.

Assuming that it's flagging the last record per dimension A in load order:

table1: 
LOAD * INLINE [ 
    A, B 
    1, a 
    1, b 
    1, c 
    2, a 
    2, b 
    3, a 
]; 


Left Join (table1) 
LOAD A, LastValue(B) as B, 1 as Flag
Resident table1 
Group By A; 

View solution in original post

5 Replies
MarcoWedel

Hi,

maybe something like this?

QlikCommunity_Thread_210210_Pic1.JPG

table1:

LOAD RecNo() as ID, * INLINE [

    A, B

    1, a

    1, b

    1, c

    2, a

    2, b

    3, a

];

Left Join (table1)

LOAD *, 1 as Flag

Resident table1

Where A<>Previous(A)

Order By ID desc;

DROP Field ID;

hope this helps

regards

Marco

maxgro
MVP
MVP

another solution could be

table1: 

LOAD * INLINE [ 

    A, B 

    1, a 

    1, b 

    1, c 

    2, a 

    2, b 

    3, a 

]; 

Left Join (table1) 

LOAD A, MaxString(B) as B, 1 as Flag

Resident table1 

Group By A; 


1.png

MarcoWedel

can you elaborate on the condition that defines your flag?

regards

Marco

swuehl
MVP
MVP

Yes, a short explanation how the flag is defined would be more than helpful.

Assuming that it's flagging the last record per dimension A in load order:

table1: 
LOAD * INLINE [ 
    A, B 
    1, a 
    1, b 
    1, c 
    2, a 
    2, b 
    3, a 
]; 


Left Join (table1) 
LOAD A, LastValue(B) as B, 1 as Flag
Resident table1 
Group By A; 

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this script

Data:

LOAD *,

RowNo() AS Sno

INLINE [

    A, B

    1, a

    1, b

    1, c

    2, a

    2, b

    3, a

];

LEFT JOIN(Data)

LOAD

A,

Max(Sno) AS Sno,

1 AS Flag

RESIDENT Data

Group By A;

Regards,

Jagan.