cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

New Column BAsed on Keywords

Hi Guys, new to PowerBi and really need some help.

 

I have a table called Leads and it looks like the below:

 

NameJob Title
Joe BloggsReporter Analyst
James CloneyData Reporter

 

I need to add a new column to this table based on predefined (i have a list myself) keywords from the Job Title column. For example, the above table should now look like this:

 

NameJob TitleMain Title
Joe BloggsReporter AnalystReporter
James CloneyData ReporterReporter

 

As you can see the new column was based on taking the keyword "Reporter" from the Job title column and then putting that as a value on the Main Title column.

 

I know how to add a new column but not sure what functions I can use to populate the correct values in that column?

 

Any help would be much appreciated, thanks!

4 REPLIES 4
Greg_Deckler
Super User
Super User

I would use a SWITCH(TRUE() statement and SEARCH or FIND

 

SWITCH(TRUE(),

 SEARCH("Reporter",[Column]),"Reporter",

 SEARCH("Something else",[Column]),"Booger",

 "Some default value"

)


@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition
Anonymous
Not applicable

 Thank you so much for your quick response.

 

When I selected to add a new column and then entered the below in the formula box it gave me below error:

 

Function 'SWITCH' does not support comparing values of type True/False with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.

@Anonymous  - OK, use this instead, sorry:

 

Column =
SWITCH(TRUE(),
SEARCH("Reporter",[Job Title],,-1)<>-1,"Reporter",
"Something else"
)

@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition
Anonymous
Not applicable

Wow that's amazing!

 

Quick question, if i have more keywords within the column can I just keep adding them on in the query?

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!