Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
jcharles
Contributor III
Contributor III

Help with IF please


I have a table in which two of the columns are a number column and the other is a name column as follows:

BranchIDBranchName
1Specialist - Tax
2Durban
3Northam
4Specialist - Personal Finance
5PMB

I want to say that wherever part of the word 'Spec' is found it must be aliased as a Specialist Department and if it does not have 'Spec' then it is a branch.

I tried this but when I do a list box on BRANCHTYPE it give me only BRANCH. How do I get this to work?

IF(BranchName = 'Spec*', 'SPECIALIST' , 'BRANCH') AS BRANCHTYPE

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

Or

IF(WildMatch(BranchName, 'Spec*'), 'SPECIALIST', 'BRANCH') as BRANCHTYPE

View solution in original post

12 Replies
MK_QSL
MVP
MVP

IF(WildMatch(BranchName) = 'Spec*', 'SPECIALIST' , 'BRANCH') AS BRANCHTYPE

MK_QSL
MVP
MVP

Or

IF(WildMatch(BranchName, 'Spec*'), 'SPECIALIST', 'BRANCH') as BRANCHTYPE

sujeetsingh
Master III
Master III

WildMatch () is the best optimised way to write it .

Well you can also write it as

IF(BranchName = 'Spec*' OR BranchName = 'SPECIALIST'

           OR BranchName = 'BRANCH') AS BRANCHTYPE

MayilVahanan

HI

Try like this

IF(WildMatch(BranchName, 'Spec*'), 'SPECIALIST', 'BRANCH') as BRANCHTYPE


WildMatch() helps to achieve this.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this in script

LOAD

*,

If(Findoneof('Specialist - Personal Finance', 'Spec'), 'SPECIALIST', 'BRANCH') as BRANCHTYPE

FROM DataSource;

Regards,

Jagan.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Jagan, I don't really understand what your code does except defining a BRANCHTYPE column that is filled with 'SPECIALIST' for every record loaded... Is there some magical trick in this function?

Peter

jagan
Luminary Alumni
Luminary Alumni

Hi Peter,

FindOneOf() - will return the count given substring in a string, if it is >0, then SPECIALIST otherwise BRANCH value is loaded into the BRANCHTYPE column.  Now you can use this column directly in Listbox/Dimension in chart.  Hope this helps you.

Regards,

Jagan.

jonathandienst
Partner - Champion III
Partner - Champion III

Manish Kachhia wrote:

Or

IF(WildMatch(BranchName, 'Spec*'), 'SPECIALIST', 'BRANCH') as BRANCHTYPE

This is the correct answer. The field will contain SPECIALIST if the branch name starts with Spec and BRANCH otherwise.

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Peter_Cammaert
Partner - Champion III
Partner - Champion III

You're describing the index() function, aren't you?

Peter