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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Alice08
Helper III
Helper III

How to search for a specific text within column in power bi using DAX

I want to search for a text called "Sprint 1" within column "Iteration Path", but this column contains value as "Sprint 11" ,"Sprint 12" etc...

How can i limit the search and find the exact match?

1 ACCEPTED SOLUTION

Thanks for sharing the exact values from the data. In this case you could try following code:-

 

Column_ = 
VAR _search =
    SEARCH ( "Sprint 1", [Iteration Path] )
VAR _search_sprint =
    MID ( [Iteration Path], _search, LEN ( [Iteration Path] ) )
RETURN
    IF ( _search_sprint = "Sprint 1", TRUE (), FALSE () )

Samarth_18_0-1720942941585.png

 

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

12 REPLIES 12
Sakshi_Kank_08
New Member

ExactMatch = IF(
[Iteration Path] = "Sprint 1",
"True",
"False"
)

          

ExactMatch

Iteration Path

Sprint 1                   

True
Sprint 11False
Sprint 12 False
Sprint 1True
Sprint 10 False
Sprint 2           False

 

Thejeswar
Community Champion
Community Champion

Hi @Alice08 ,
Using CONTAINSSTRING() and CONTAINSSTRINGEXACT() will give the same output in this case. Find below the screenshot

 

Thejeswar_0-1720881569216.png

 

Instead you have to use either of these functions with a customized condition like the one given below

 

IF(AND(CONTAINSSTRINGEXACT(SELECTEDVALUE('Table'[SprintName]), "Sprint 1"), LEN(SELECTEDVALUE('Table'[SprintName])) == LEN("Sprint 1")), TRUE, FALSE)

 

Thejeswar_1-1720881630830.png

 

 

Regards,

 

@Thejeswar  I have tried this but its giving same output , i want to create a column which will contain exact match for Sprint 1.

Now in this case Sprint 10 as well it is detecting as Sprint 1.

 

Hi @Alice08 ,

You should create a measure using the DAX formula I shared.

 

If you want to create a column that gives the same output, you need to slightly modify the DAX formula like given below

IF(AND(CONTAINSSTRINGEXACT('Table'[SprintName], "Sprint 1"), LEN('Table'[SprintName]) == LEN("Sprint 1")), TRUE, FALSE)

 

Regards,

This is giving me False output for all.

Samarth_18
Community Champion
Community Champion

Hi @Alice08 ,

 

You can use the CONTAINSSTRINGEXACT function. Refer the below article.

 

https://learn.microsoft.com/en-us/dax/containsstringexact-function-dax

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

@Samarth_18  This is again giving me same output.

Hi @Alice08 , Please try this:-

Column = IF(EXACT('Table'[Iteration Path],"Sprint 1"),TRUE(),FALSE())

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

This as well not working.

It seems something is missing. I have replicated the same scenario and it works fine as a column

 

Samarth_18_0-1720939452639.png

and if you are trying to create a measure then use this code:-

Measure 2 = IF(EXACT(MAX('Table'[Iteration Path]),"Sprint 1"),TRUE(),FALSE())

Samarth_18_1-1720939615969.png

If it still has not helped. I request you to please share your sample file.

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

i think its not working for me because Iteration Path column does not contain the exact value as "Sprint 1" it has values like "Project\Q1\Sprint 1"

Thanks for sharing the exact values from the data. In this case you could try following code:-

 

Column_ = 
VAR _search =
    SEARCH ( "Sprint 1", [Iteration Path] )
VAR _search_sprint =
    MID ( [Iteration Path], _search, LEN ( [Iteration Path] ) )
RETURN
    IF ( _search_sprint = "Sprint 1", TRUE (), FALSE () )

Samarth_18_0-1720942941585.png

 

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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