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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Zabeer
Helper I
Helper I

Extract field value in Power Query to a new column based on conditions

Hello everyone,

I wish to extract specific values in a column to a new column. The rule is that the values need to start with 75 or 76 and can have maximum of 10 digits. Examples below should make it clear.

InputResult
PO: 7500013234 - SO -128327500013234
SO117934 PO-75000123127500012312
PN; 15800-024A/7600012040  7600012040
PO7500012030 -SO-123127500012030

 

Kindly help. I would need this on Power Query.
Thank you.

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Zabeer,

 

Try this custom column in Power Query:

 

if Text.PositionOf([Input], "75") <> - 1 then
  Text.Middle([Input], Text.PositionOf([Input], "75"), 10)
else if Text.PositionOf([Input], "76") <> - 1 then
  Text.Middle([Input], Text.PositionOf([Input], "76"), 10)
else
  null

 

DataInsights_0-1626446655612.png

 





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

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Zabeer
Helper I
Helper I

@DataInsights Worked like a charm. Thank you! 🙂

DataInsights
Super User
Super User

@Zabeer,

 

Try this custom column in Power Query:

 

if Text.PositionOf([Input], "75") <> - 1 then
  Text.Middle([Input], Text.PositionOf([Input], "75"), 10)
else if Text.PositionOf([Input], "76") <> - 1 then
  Text.Middle([Input], Text.PositionOf([Input], "76"), 10)
else
  null

 

DataInsights_0-1626446655612.png

 





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

Proud to be a Super User!




Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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