Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MatthewFiero
Helper I
Helper I

If a column contains (or starts with) a certain letter then output a certain column

Hello Power BI Community,

 

What I thought would be a simple calculation has had me at this for a few hours now., After searching a bit on the community I couldn't find any previous answers that could assist me. Though I am sure this is simple enough it has been dealt with on several occasions perhaps I am not searching correctly.

 

I was hoping to do this as a measure but I'm thinking this would be better as a custom column. 

 

Basically I have a list of Items in [Column A] that I want to output to a different column but only if [Column B] contains (or starts with) the letter "M". If [Column] B does not start with "M" then null

 

I've tried many different ways but I think I got closest using this:

 

=if List.Contains([Column B],"M", [Column A] else null

 

Clearly I have something wrong. 

 

Can anyone help point me in the right direction. Honestly, with M or DAX I am having difficulties searching for anything or starting with and I know this knowledge will come in time. 

 

Thank you,
Matthew

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@MatthewFiero , if it only starts with M

 

=if Text.Left([Column B]) = "M" then [Column A] else null

 

if it is contains M

=if Text.Contains([Column B],"M") then [Column A] else null

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@MatthewFiero , if it only starts with M

 

=if Text.Left([Column B]) = "M" then [Column A] else null

 

if it is contains M

=if Text.Contains([Column B],"M") then [Column A] else null

Hello,

 

would it be possible to select Dynamically each Column which Start with the word "Column" ?? To add a conditional column?

 

 

Someting like ,  

 

If #"My list of columns"  Text.contains ("%") then A else B )

 

?

MatthewFiero
Helper I
Helper I

Okay so seconds after I click sent I realized I can just create a conditional column. I must be tired.

 

= Table.AddColumn(#"Filtered Rows1", "Custom", each if Text.Contains([Column A], "M") then [Column B] else null)

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.