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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
mdrammeh
Helper III
Helper III

How to Create a Filter To Identify First 3 Text Characters - In Power Query

I have a database with millions of records. Each record is identified by a number and text description. Therefore, I want to create a lookup by the first 3 text characters that begin with "EDT" and rename it as "External" and if it does not begin with "EDT" then call it "Internal". 

 

Example:

 

ELM-HEMLOCK 1.6MI 1PH RBLD PITA1328 - This should return "Internal"

EDT:  OREILLY RD BRODERICK RD 1.7MI 1PH OH RBLD WINNECONNE - This should return "External"

 

Thanks in advance.

1 ACCEPTED SOLUTION

No that is totally fine - we are here to help 🙂

 

You forgot the "if" statement !

 

If you don't want to code manually, have a look at the method @Vvelarde suggests above ! It uses simple dropdown lists and you are basically generating (M) code without writing it 🙂

View solution in original post

6 REPLIES 6
Datatouille
Solution Sage
Solution Sage

HI @mdrammeh

 

I guess you want to perform this task in a calculated column?

 

You can use Text.Start which is the equivalent of Left function in Excel/DAX.

 

Create a custom column from Power Query:

if Text.Start([Pays],3) = "EDT" then "External" else "Internal"

 

Be careful Power Query formula language is case sensitive !

So let's say the Column with the description is titled: "Project Description". How would I rewrite this in Power Query?

 

if Text.Start([Pays],3) = "EDT" then "External" else "Internal"

 

Sorry "Pays" was just an example.

Put the name of the column which contains your codes or use @Vvelarde method suggested above 🙂

Error 2.PNGI think am missing something still. Sorry for being such a pain 🙂

No that is totally fine - we are here to help 🙂

 

You forgot the "if" statement !

 

If you don't want to code manually, have a look at the method @Vvelarde suggests above ! It uses simple dropdown lists and you are basically generating (M) code without writing it 🙂

Vvelarde
Community Champion
Community Champion

@mdrammeh

 

Hi, in Edit Query--Add Column - Select Conditional Column

 

EDITQUERY.png




Lima - Peru

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.