Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for
Did you mean:
Specialist

## Flag in If condition with 'Not Exists' functionality

Hi All,

I was trying to create a flag which distinguishes special and normal orders.

Order,  Product, INS

12345   ABC       Y

12345    DEF      Y

12345     GHI

12345     JKL

67891    TYU

If an order has atleast one INS specified then it by default becomes special type and give 'Y' .

Only if the order has no INS, then give 'N'.

O/P:

Flag Y has only 12345

Flag N has only 67891

Any help is highly appreciated.

1 Solution

Accepted Solutions
MVP

Another approach:

Table1:
[
Order, Product, INS
12345,ABC,Y
12345,DEF,Y
12345,GHI
12345,JKL
67891,TYU
]
;

Table2:
LEFT JOIN
LOAD Order, If(Maxstring(INS) = 'Y', 'Y', 'N') as Flag
Resident Table1
GROUP BY Order;

7 Replies
MVP

May be this:

Table:

Product,

If(Len(Trim(INS)) > 0, INS) as INS;

LOAD * Inline [

Order,  Product, INS

12345,  ABC,      Y

12345,  DEF,      Y

12345,  GHI,

12345,  JKL,

67891,  TYU,

];

Left Join(Table)

'Y' as INS1

Resident Table

Where INS = 'Y';

FinalTable:

NoConcatenate

If(Len(Trim(INS1)) = 0, 'N', INS1) as INS,

Product

Resident Table;

DROP Table Table;

MVP

Another approach:

Table1:
[
Order, Product, INS
12345,ABC,Y
12345,DEF,Y
12345,GHI
12345,JKL
67891,TYU
]
;

Table2:
LEFT JOIN
LOAD Order, If(Maxstring(INS) = 'Y', 'Y', 'N') as Flag
Resident Table1
GROUP BY Order;

MVP

Elegant

MVP

like this?

Table:

LOAD * Inline [

Order,  Product, INS

12345,  ABC,      Y

12345,  DEF,      Y

12345,  GHI,

12345,  JKL,

67891,  TYU,

];

Left Join(Table)

load Order, if(match(MaxString(INS), 'Y'), 'Y', 'N') as Flag

Resident Table

group by Order;

Specialist
Author

Thanks bro. Sunny

Specialist
Author

Thanks swueh1

Specialist
Author

Thanks maxgro

Community Browser