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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

if nested statement

hi i am trying to complete the following logic in my application.

however, either one statement works or the other but not together.

the logic is that where one of the values is missing take the other.

for example

works!

if([Master_Item.Product Group] ='x',[Product Group]

works!

if([Master_Item.Product Group] ='x',[Cost_Center_Mapping.Product Group])

Does not work.

if([Master_Item.Product Group] ='x',[Product Group],

(if([Master_Item.Product Group] = 'x' and [Product Group] = '',

[Cost_Center_Mapping.Product Group])))

any help is greatly appreciated. i have attached application for further analysis if needed,

Best

Brad

5 Replies
giakoum
Partner - Master II
Partner - Master II

try

=if([Master_Item.Product Group] ='x'  and [Product Group] <> '',[Product Group],

(if([Master_Item.Product Group] = 'x' and [Product Group] = '',

[Cost_Center_Mapping.Product Group])))

but I noticed that [Cost_Center_Mapping.Product Group] is null when any [Product Group is selected

Not applicable
Author

Hi,

Try hereunder

if([Master_Item.Product Group] ='x',[Product Group],

if([Master_Item.Product Group] = 'x' and [Product Group] = '',

[Cost_Center_Mapping.Product Group], 'not found'))

Now the syntax is ok. Not sure about your data.

Regards,

Gerrit

rustyfishbones
Master II
Master II

Hi,

I don't think you need to have a parentheseis around the 2nd IF Statement

Please see the attached

Regards

Al

israrkhan
Specialist II
Specialist II

try this one:

if([Master_Item.Product Group] ='x',[Product Group],if([Master_Item.Product Group] = 'x' and [Product Group] = '',

[Cost_Center_Mapping.Product Group], Null))

Not applicable
Author

Try Below one: Please use LEN function while comparing the space in the fields.

if(LEN(TRIM([Product Group]) = 0 AND [Master_Item.Product Group] = 'x' , [Cost_Center_Mapping.Product Group] ,

  IF ([Master_Item.Product Group] = 'x' , [Product Group] , 'Not Found')) AS FIELDNAME