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! Request now

Reply
cj_sh
Regular Visitor

Finding fix text in the string

I am fetching data from SharePoint list.

 

Requirement:

there is a string, from which I need to find two fix words (AD and PC), and send the finding into a new column.

 

 

1 ACCEPTED SOLUTION

Hi @cj_sh ,

 

You could add if() function to return the results you want.

if
Text.Contains([Column1],"PC")=true
then
[Column1]
else
"Your other result"

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

7 REPLIES 7
mussaenda
Super User
Super User

Have you solved your problem @cj_sh ?

Anonymous
Not applicable

Hi @cj_sh ,

 

The easiest way to achieve this is Conditional Columns in Power Query. 

Please Use Operator as contains or Equal according to your other options.

Please use the attached picture as reference.

 

Best Regards,

Gaurav Raj SinghConditional Column.PNG

mussaenda
Super User
Super User

you can do it on power query or dax

 

in power query, you can create a conditional column and put your condition there.

in dax, you can use containsstring function to find your desired words and use if statement

@mussaenda  Thanks, I don't know why my query editor is not showing ContainsString function among the choices.

 

but I am trying Text.Contains([ColumnName],"AD"),  and it is giving me True/False  whereever AD in the string. 

Now I am getting challenge in value AD in the column instead of True.

 

Can you help me in that.. 

Hi @cj_sh ,

 

The language used in Power Query is M while that in the designer is DAX that's why you can't use CONTAINSTRING in the query editor.  For your requirement, you can try this in DAX:

 

New Column =
//will return blank if both criteria are not met
IF (
    CONTAINSSTRING ( Table[Column], "AD" ) && CONTAINSSTRING ( Table[Column], "PC" ),
    Table[Column]
)

 

 

EDIT:

M is case-sensitive.  That's why you are getting a TRUE/FALSE result instead of just either. You can wrap your column first in Text.Upper before using Text.Contains so it would be something like: 

Text.Contains ( Text.Lower ( [Column] ) )




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Anonymous
Not applicable

Hi @danextian  ,

 

I think in this situation OR will be the right condition, not AND. 

So in DAX use the below formula,

 

New Column =
//will return blank if both criteria are not met
IF (
    CONTAINSSTRING ( Table[Column], "AD" ) || CONTAINSSTRING ( Table[Column], "PC" ),
    Table[Column]
)

 

Hi @cj_sh ,

 

You could add if() function to return the results you want.

if
Text.Contains([Column1],"PC")=true
then
[Column1]
else
"Your other result"

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

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