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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Text matching

Hi,

 

I am trying to calculate

If Part no contains 0 or - or both then print part no to the K-parts column.

 

sbhan4_0-1601761915095.png

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Anonymous 

you can also try to create a column

Column = 
VAR a=find("0",'Table (2)'[Part No],1,0)
VAR b=find("-",'Table (2)'[Part No],1,0)
return if(a=0&&b=0,"NA",'Table (2)'[Part No])

1.PNG

I am not sure why your last row contains 0, but your expected result is NA.

 





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

Proud to be a Super User!




View solution in original post

4 REPLIES 4
ryan_mayu
Super User
Super User

@Anonymous 

you can also try to create a column

Column = 
VAR a=find("0",'Table (2)'[Part No],1,0)
VAR b=find("-",'Table (2)'[Part No],1,0)
return if(a=0&&b=0,"NA",'Table (2)'[Part No])

1.PNG

I am not sure why your last row contains 0, but your expected result is NA.

 





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

Proud to be a Super User!




Anonymous
Not applicable

@ryan_mayu Thank you for your help.

 

My bad.. the last row should be NA.

lbendlin
Super User
Super User

Your last sample line is inconsistent.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8jY0MjbRNTQ2MTVTitWJVgJxTc3MwWwgy8DSwhsu7u0ZomtmbmoCETEzt7A0MFSKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Part No" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "K- parts", each if Text.Contains([Part No],"-") or Text.Contains([Part No],"0") then [Part No] else "NA")
in
    #"Added Custom"

  Anyway, here's the formula. Power Query is pretty verbatim.  

Anonymous
Not applicable

@Syndicate_Admin

Can you show me in pbix file?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.