Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good day,
I want to create a new field "Label"
So I want to group the following data with if statement to create the "Label" field:
NIKE-986543, NIKE-776543, NIKE-098766, NIKE-445321
ADIDAS-587415, ADIDAS-866598
PUMA-694528, PUMA-007945, PUMA-377326
REDBAT-277539, REDBAT-800694
Your help will be highly appreciated
Thanks.....
Hey
You can do this by creating nested if statements -
If( Match ( Code , '986543' , '776543' , '098766' , '445321') , 'NIKE',
If( Match ( Code , '587415' , '866598') , 'ADIDAS' ,
If( Match ( Code , '694528' , '007945' , '377326') , 'PUMA',
If( Match ( Code , '277539' , '800694') , 'REDBAT' )))) AS Label
Thanks
@Charlz_1 if I understood correctly, you can use :
PICK(WildMatch(Field,'*NIKE*','*ADIDAS*','*PUMA*'),'NIKE','ADIDAS','PUMA') as Label
example :
Test:
LOAD *,PICK(WildMatch(Field,'*NIKE*','*ADIDAS*','*PUMA*'),'NIKE','ADIDAS','PUMA') as Label INLINE [
Field
NIKE-986543
ADIDAS-587415
PUMA-694528
];
output:
What about other data that appears under the same label?
The solution from Taoufiq_Zarra will assign the label value to all rows containing the defined text strings. So if there are 3 values in the same row; e.g. , PUMA-694528, PUMA-007945, PUMA-377326 -> this row will receive a value in field Label = 'PUMA'. Similarly all rows containing the string 'PUMA' will be labeled 'PUMA'.
If this solution is not suitable for your use case, it would help if you would provide same sample data (a few rows) and describe what you would like to achieve.
Hello @Charlz_1 ,
use subfield() for this
try like this
subfield(fieldName,"_",1) as Label
Regards,
Prashant Sangle
Hey
You can do this by creating nested if statements -
If( Match ( Code , '986543' , '776543' , '098766' , '445321') , 'NIKE',
If( Match ( Code , '587415' , '866598') , 'ADIDAS' ,
If( Match ( Code , '694528' , '007945' , '377326') , 'PUMA',
If( Match ( Code , '277539' , '800694') , 'REDBAT' )))) AS Label
Thanks
Thanks a lot, it worked.