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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Extract number with condition

Hello,

 

I have this column :

 

DFS-PI1

DFS-PI2

01234

P393

BLABLABLA

 

And I want to create a column that extract the last number only if it starts with "DFS-PI", otherwise show null. The result would be:

1

2

null

null

null

 

 

I can't find a way to do that. Anyone can help me please?

Thank you

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

In Power Query you would create a new column with the following calculation:

if
  Text.StartsWith([yourColumnName], "DFS-PI")
then
  Text.End([yourColumnName], 1)
else
  null

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

In Power Query you would create a new column with the following calculation:

if
  Text.StartsWith([yourColumnName], "DFS-PI")
then
  Text.End([yourColumnName], 1)
else
  null

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




jppv20
Solution Sage
Solution Sage

Hi @Anonymous 

 

This should work:

Extract = IF(LEFT('Table'[Column],6)="DFS-PI",RIGHT('Table'[Column],1),BLANK())
 
Jori

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.