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

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Search string for certain word (Calculated Dimension)

Hi

I want to create a calculated dimension which searches in a string for a certain word, and then if the string contains that word, is should be named something

Example

Dimension name : Field1

Field 1 contains below data strings

- shoe_OLD_4512

- Shirt45OLD_78942

- ShoeNEW_5698

- Shoe2OLD_56821

......

I want a calculated dimension that searches every string for the word Old, if the string contains the word OLD, then its should be named Old, otherwise New.

However, I can only seem to find a answer which searches the strings based on a locked position of the word your a searching for. Meaning that the word OLD should be in the same place every time for the calculated dimension to be working.

Is there a way to achieve it?

Any helped is very much appreciated.

Best

Stefan

1 Solution

Accepted Solutions
antoniotiman
Master III
Master III

Hi Stefan

Calculated Dimension

=If(WildMatch(Field1,'*OLD*'),'Old','New')

Regards,

Antonio

View solution in original post

5 Replies
richard_chilvers
Specialist
Specialist

How about using INDEX?

IF(INDEX(Field1,'OLD')>0,'Old', 'New')

devarasu07
Master II
Master II

Hi,

Try like this

load *

,Replace(Dim,'OLD','New') as Cal

;

LOAD * INLINE [

  Dim

    shoe_OLD_4512

    Shirt45OLD_78942

    ShoeNEW_5698

    Shoe2OLD_56821

];

Untitled.png

Sergey_Shuklin
Specialist
Specialist

Hello, Stefan!

You can use more intuitive expression: if(Filed1 like *old*,'OLD','NEW').

The one of advantages is it's not a case sensitive. So it's equaly will search for "OLD", "Old", "old" etc.

antoniotiman
Master III
Master III

Hi Stefan

Calculated Dimension

=If(WildMatch(Field1,'*OLD*'),'Old','New')

Regards,

Antonio

Anonymous
Not applicable
Author

Hi Antonio

That worked! How easy can it be

Thanks to you all for responding to quick

Regards

Stefan