Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
YG
Contributor III
Contributor III

Qlik Sense rename with IF works for some but not others?

Hi All,

 

I am having a dilemma with renaming with IF condition and when I use with some operators (wildmatch)  with many IF conditions it works but couple of conditions it doesn't. 

 

Below Yellow highlighted names I want to change it to just "Failed" and "Success"

YG_0-1677735846223.png

This is what I tried so far,

YG_1-1677735912257.png

=if(wildmatch(event_type, 'AddPasswordSuccess'), 'Success',
     if(wildmatch(event_type, 'AddPasswordFailed'),'Failed'))

= if (event_type='AddPasswordSuccess', 'Success',
      if(event_type='AddPasswordFailed', 'Failed'))

NON of the above works,  BUT below is working for another Dimension

=if(wildmatch(channel_function,'reg-pin*'),'reg-pin',
if(wildmatch(channel_function,'reg-pwd*'),'reg-pwd'))

I dont understand how this Dimensions are similar but one works but the other. Anyone who can help would be really appreciated. Thanks in advance 

 

 

Labels (4)
1 Solution

Accepted Solutions
YG
Contributor III
Contributor III
Author

I have no Idea Why but Used the same expression before,

 

=if (event_type=('AddPasswordSuccess'), 'Success',
if(event_type=('AddPasswordFailed'), 'Failed'))

 

But wanted the fields displayed to the "Right" and it is working, But don't understand why not in bottom

 

YG_0-1678062414633.png

 

View solution in original post

11 Replies
henrikalmen
Specialist
Specialist

It's difficult to see in your image, but it seems your field is named event_typ_name or something like that, but you have just used event_type?

Apart from that, I just want to mention that you could use a simpler expression:
=replace(event_type_name, 'AddPassword', '')

And one last thing: wildmatch is generally used when you need wildcards in the matched phrase, like in your example with channel_function. When you are matching full phrases, you can use match(). I suppose it many times doesn't really matter, but possibly match() evaluates faster than wildmatch().

ajaykakkar93
Specialist III
Specialist III

hi,

please try this
=if(wildmatch(event_type, '*Success*'), 'Success',
     if(wildmatch(event_type, '*Failed*'),'Failed'))


Hope it helps

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting

marcus_sommer

I suggest to consider to apply such adjustments within the script and/or using multiple fields for it, like ID + NameLong + NameShort as well as various categorizing-measurements - maybe within an extra dimension-table.

Beside this I think your UI approach could be simplified by:

replace(TheRightEventField, 'AddPassword', '')

YG
Contributor III
Contributor III
Author

Thanks @ajaykakkar93  for looking at this, i tested the expression and it did not change the name at all same issue.

YG_0-1677797668101.png

 

YG_1-1677797689606.png

 

YG
Contributor III
Contributor III
Author

Thanks @henrikalmen  for taking time to look at it. Sorry the image wasn't clear. Below is more better pic. I tried your Expression : =replace(event_type,'AddPasswordSuccess', 'Success') It did not replace anything or the lable I wanted to change,

YG_0-1677810923394.pngYG_1-1677810964394.png

 

YG
Contributor III
Contributor III
Author

Thanks Marcus for your suggestion, I actually don't have access to "Data manger "  (Do edit the script) unfortunately. So all I can do is create Variables, Measures and Dimension using Expression to change and implement data given to me. 

henrikalmen
Specialist
Specialist

if you have tried to write your if-expression in the correct place, it would have given you NULL if it didn't work. It would not have given you the original value. So I'm thinking you have written that expression in the wrong place. Can you make an image of also where you have your expression (probably an image of what you master dimension settings are)?

marcus_sommer

That you have no access to the data-model doesn't mean that's not changeable there - just create such a task for the responsible team. In general should be none renaming be necessary within the UI else all needed fields with the right terminology should be native available.

IMO that's not nice to have else a must because it reduced the development efforts within the UI and saved significantly performance. Further only with native fields you are able to implement advanced views which needs features like aggr() and/or total.

YG
Contributor III
Contributor III
Author

Thanks @henrikalmen  You could be right on this as I did the expression doing it here,

YG_0-1677908915683.png

Then edited the Expression

 

YG_1-1677909099021.png