Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
stuwannop
Partner - Creator III
Partner - Creator III

Counting if a text string appears

Hi everyone

I'm having a little troble in my script. I have the following example list of values in a field called "Campaign Type":

Sage Vendor, Microsoft Vendor, Digital Campaign, Pegasus Silo, Sage Silo (there are more but will serve for this)

What I want to do is create another field called "Campaign Group". The Campaign Group will be specified as follows:

1. Anywhere  the word "Vendor" appears let Campaign Group = Vendor.

2. Anywhere the word "Silo" appears let Campaign Group = Silo

3. Anywhere the word "Digital" Appears let Campaign Group = Digital

So each row is either a Vendor, Silo or Digital Campaign.

I could do a lengthy IF statement for each campaign type but I have a few of them and more could be added. I'm happy for it to be an IF statement though if I can just group up the Campaign Types.

I've tried a few things like substringcount but I can't seem to get anywhere so I was hoping for a push in the right direction.

Thanks

Stu

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

In your script:

     Pick(WildMatch([Campaign Type], '*Vendor*', '*Silo*', '*Digital*')+1, 'Other', 'Vendor', 'Silo', 'Digital')

          as [Campaign Group]

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

2 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

In your script:

     Pick(WildMatch([Campaign Type], '*Vendor*', '*Silo*', '*Digital*')+1, 'Other', 'Vendor', 'Silo', 'Digital')

          as [Campaign Group]

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
stuwannop
Partner - Creator III
Partner - Creator III
Author

That's great Jonathan thanks for such a quick response. I was going to ask you how that works as I didn't get the significance of the +1 but I've took it to bits and found the logic behind it.

Thanks again.

Stu