cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
melina Member
Member

if column contain keywords

Hi All,

 

My question similar like this link https://community.powerbi.com/t5/Desktop/DAX-If-a-column-contains-a-certain-value-then-a-column-cont... 

 

but i involving around 30 of keywords on title column

My keywords is factory.Example F01_shiplannt_19062017

 

my condition like this :

If F01, column category equals to F01,

IF F02, column category equals to F02,

.

.

.

IF F30,column cateogry equals to F30.

The problem is i have to write so many condition, It is there any simplest way?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Ross73312 Super Contributor
Super Contributor

Re: if column contain keywords

We can get cleverer.  Firstly, what is the formula to what you care about?  Does it have to be the first 3 characters?  Do you only want the ones that begin with F?

For example you could do something like:

My Measure = IF(
	MID('YourTable'[Title], 4, 1) = "_",
	LEFT([Title], 3),
	""
)

This will check if your title starts with XXX_ and the make the result XXX.

Does this idea help?

 


   

              Did I answer your question? Mark my post as a solution!
       

Proud to be a Datanaut!


   


View solution in original post

6 REPLIES 6
Ross73312 Super Contributor
Super Contributor

Re: if column contain keywords

Are your first 3 characters always FXX?  If thats the case i would do something like this:

My Measure = SWITCH(
	LEFT([Title], 3),
	"F01", <Thing to do>,
	"F02", <Thing to do2>,
	"F03", <Thing to do3>,
	<Thing not to do>
)

Naturally mine has only 3 options and an "Else".  But you get the picture.

 


   

              Did I answer your question? Mark my post as a solution!
       

Proud to be a Datanaut!


   


melina Member
Member

Re: if column contain keywords

Thanks for the answer,

 

yes, it always FXX. So i need to do one by one condition until F30?
How if i would like to do in advance editor?

Ross73312 Super Contributor
Super Contributor

Re: if column contain keywords

That version i gave you was for a calculated column in DAX, rather than in the "Edit Queries" section.  Its not quite so easy in Power Query, however i'm not an expert at Power Query.

 

This should work fine as a calculated column.


   

              Did I answer your question? Mark my post as a solution!
       

Proud to be a Datanaut!


   


melina Member
Member

Re: if column contain keywords

So, is no other way just like copy for the first FXX?

Because i have dataset that the factory always change.

 

 

like this :

if (title,F01) then just copy title from the first 3 letter.

 

if i create one by one from F01 and F30, it might be possible if in future there is new factory.

 

 

 

Ross73312 Super Contributor
Super Contributor

Re: if column contain keywords

We can get cleverer.  Firstly, what is the formula to what you care about?  Does it have to be the first 3 characters?  Do you only want the ones that begin with F?

For example you could do something like:

My Measure = IF(
	MID('YourTable'[Title], 4, 1) = "_",
	LEFT([Title], 3),
	""
)

This will check if your title starts with XXX_ and the make the result XXX.

Does this idea help?

 


   

              Did I answer your question? Mark my post as a solution!
       

Proud to be a Datanaut!


   


View solution in original post

melina Member
Member

Re: if column contain keywords

yes! you are correct.Thanks  a lot!

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors