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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors