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

Announcements
Now accepting applications for the Qlik Luminary and Partner Ambassador Programs: Apply by July 6!
cancel
Showing results for 
Search instead for 
Did you mean: 
TomBond77
Specialist
Specialist

Replace '-' with another field value

Hi experts

attached please find the screen of a field which gives '-',  a minus to the very left.

Now I tried to replace such cases on that field with the following script:

[NodeName1] as [CDF (Level 1)],  
If([NodeName2] = '-', [NodeName1] & '-', [NodeName2]) as [CDF (Level 2)]

 

NodeName1 is always filled with a value.

But the if clause doesn't work.

 

Any ideas?

Many thanks

Tom

1 Solution

Accepted Solutions
Kushal_Chawda
MVP
MVP

may be this

If(isnull([NodeName3]) and isnull([NodeName2]), LEFT([NodeName1], 1) & '----',
If(isnull([NodeName3]) and not isnull([NodeName2]), LEFT([NodeName2], 2) & '---', [NodeName3]))
as [CDF (Level 3)]

View solution in original post

6 Replies
Kushal_Chawda
MVP
MVP

may be

If(len(trim([NodeName2])) = 0, [NodeName1] , [NodeName2]) as [CDF (Level 2)]

TomBond77
Specialist
Specialist
Author

thanks

Meanwhile I fixed it with: 
If(isnull([NodeName2]), LEFT([NodeName1], 1) & '-', [NodeName2]) as [CDF (Level 2)].

 

But I have another challenge, still not fixed:

If(isnull([NodeName3]) and if(isnull([NodeName2]), LEFT([NodeName1], 1) & '----'), [NodeName3]) as [CDF (Level 3)]

Can you please check if the brackets are correct? I don't get any syntax errors, but don't get the wished result.

Thanks!

Kushal_Chawda
MVP
MVP

If(isnull([NodeName3]) and isnull([NodeName2]), LEFT([NodeName1], 1) & '----'), [NodeName3]) as [CDF (Level 3)]

TomBond77
Specialist
Specialist
Author

Thanks, this works!

Now I have enhanced this coding by:

If(isnull([NodeName3]) and isnull([NodeName2]), LEFT([NodeName1], 1) & '----', [NodeName3])
or (If(isnull([NodeName3]) and not isnull([NodeName2]), LEFT([NodeName2], 2) & '---', [NodeName3]))
as [CDF (Level 3)]

Now the results again are not correct. The first line of the coding worked fine, added by the second line it is not working. Any idea where the code is incorrect?

Kushal_Chawda
MVP
MVP

may be this

If(isnull([NodeName3]) and isnull([NodeName2]), LEFT([NodeName1], 1) & '----',
If(isnull([NodeName3]) and not isnull([NodeName2]), LEFT([NodeName2], 2) & '---', [NodeName3]))
as [CDF (Level 3)]

TomBond77
Specialist
Specialist
Author

GREAT! 

Thank you!