Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello all,
I have the following IF statement in my script:
If(CategoryName = 'Women's Clothes' or CategoryName= 'Sportswear' or CategoryName = 'Men's Footwear', 1,0) as CategoryType
But the script won't run because Women's Clothes and Men's footwear actually contain single quotes too and Qlikview sees this as a problem.
I thought I could do:
If(CategoryName = "Women's Clothes" or CategoryName= 'Sportswear' or CategoryName = "Men's Footwear", 1,0) as CategoryType
or
If(CategoryName = [Women's Clothes] or CategoryName= 'Sportswear' or CategoryName = [Men's Footwear], 1,0) as CategoryType
But this does not work.
Does anyone know how to fix this minor issue in my IF statement please?
Try this may be:
If(Match(CategoryName, 'Women' & Chr(39) & 's Clothes', 'Sportswear', 'Men' & Chr(39) & 's Footwear'), 1, 0) as CategoryType
Script:
Table:
LOAD *,
If(Match(CategoryName, 'Women' & Chr(39) & 's Clothes', 'Sportswear', 'Men' & Chr(39) & 's Footwear'), 1, 0) as CategoryType;
LOAD * Inline [
CategoryName
Women's Clothes
Sportswear
Men's Footwear
ABC
DEF
GHI
];
Try this may be:
If(Match(CategoryName, 'Women' & Chr(39) & 's Clothes', 'Sportswear', 'Men' & Chr(39) & 's Footwear'), 1, 0) as CategoryType
Script:
Table:
LOAD *,
If(Match(CategoryName, 'Women' & Chr(39) & 's Clothes', 'Sportswear', 'Men' & Chr(39) & 's Footwear'), 1, 0) as CategoryType;
LOAD * Inline [
CategoryName
Women's Clothes
Sportswear
Men's Footwear
ABC
DEF
GHI
];
Hi Sunny,
You are a star! Thanks that works. I thought about using the Chr function but figured there might be a simpler way than that. Maybe not I guess.
I think there is also the easier option using an escape sequence with two single quotes:
Table:
LOAD *,
If(Match(CategoryName, 'Women''s Clothes', 'Sportswear', 'Men''s Footwear'), 1, 0) as CategoryType;
LOAD * Inline [
CategoryName
Women's Clothes
Sportswear
Men's Footwear
ABC
DEF
GHI
];