Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

translate names in script - with and condition

Hi All.

Really hope you could help me with the following issue.

In our script we use 'set' in order to translate some of the fields.

SET translated_make = "if(Upper($1)='SM','Samasung',$1)";

SET translated_model = "if(Upper($1)='LOCAL','PC Local',$1)";

and when we are loading the fields we are using the following functions:

Devices:

load

$(translated_make(device_make)) as Devices_device_make,

$(translated_model(device_model)) as Devices_device_model

my problem is that one of the translated names should be depends on both make&model.

let say if  device_make=Nk and device_mode=953 then I want to 'set translated make to  null value' and also to 'set translated model to a null value'.

the different now is that I have a if condition with 'and' operator.

Hope I was clear enough. can someone please advise?

thanks!

1 Solution

Accepted Solutions
anbu1984
Master III
Master III

Yes


If(Not(device_make=Nk and device_mode=953),$(translated_make(device_make))) -- If device_make is not equal to Nk and device_mode is not equal to 953, then this expr return $(translated_make(device_make))  else return null

View solution in original post

7 Replies
anbu1984
Master III
Master III

Devices:

load

If(Not(device_make=Nk and device_mode=953),$(translated_make(device_make))) as Devices_device_make,

If(Not(device_make=Nk and device_mode=953),$(translated_model(device_model))) as Devices_device_model

Not applicable
Author

load

...

if(len(device_make)>0 and len(device_model)>0, $(translated_make(device_make)), Null()) as Devices_device_make,

if(len(device_make)>0 and len(device_model)>0, $(translated_model(device_model)), Null()) as Devices_device_model

...

marcus_sommer

Often suited a mapping with applymap() such translations better - especially if there are more than a few items.

- Marcus

Not applicable
Author

Hi thank you for answering!

But how can I change the 'NK' value and the '953' Value to null? will it be null automatically after using your condition?

Not applicable
Author

hi thanks for answering

but where did you refer to the values of the device_make and device_model?

anbu1984
Master III
Master III

Yes


If(Not(device_make=Nk and device_mode=953),$(translated_make(device_make))) -- If device_make is not equal to Nk and device_mode is not equal to 953, then this expr return $(translated_make(device_make))  else return null

Not applicable
Author

Thank you!!!!! you really helped me