cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
datanau001
Helper III
Helper III

Power BI Desktop - DAX Search text string

Hello,

I created a new Dax column which uses the Search funtion as below:

Search_Version =
SWITCH (
TRUE (),
SEARCH ( "1.8.15", 'D_TT_Historic_Data_Creation_Date'[DESCRIPTION], 1, 0 ) > 0, "1.8.15",
SEARCH ( "1.8.150", 'D_TT_Historic_Data_Creation_Date'[DESCRIPTION], 1, 0 ) > 0, "1.8.150",
SEARCH ( "1.8.16", 'D_TT_Historic_Data_Creation_Date'[DESCRIPTION], 1, 0 ) > 0, "1.8.16",
SEARCH ( "1.8.160", 'D_TT_Historic_Data_Creation_Date'[DESCRIPTION], 1, 0 ) > 0, "1.8.160",
BLANK()
)

However, the search function will not differentiate the text and will show "1.8.15" and "1.8.150" as "1.8.15".

I've been trying to use wildcards like * or ? in different positions but with no success.
So, I'd like to ask your help in how I could adjust this code in order to get exactly the text match.

In case you need any other detail, just let me know.

 

Thank you
Marcelo

3 ACCEPTED SOLUTIONS
HotChilli
Super User
Super User

Change the order of the comparisons so that the more selective tests come before the less selective tests

View solution in original post

mangaus1111
Solution Sage
Solution Sage

HI @datanau001 ,

 

if you change the order it works.

 

mangaus1111_0-1667394939519.png

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thank you for the solution.

It was exactly what I was looking for.

View solution in original post

3 REPLIES 3
mangaus1111
Solution Sage
Solution Sage

HI @datanau001 ,

 

if you change the order it works.

 

mangaus1111_0-1667394939519.png

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for the solution.

It was exactly what I was looking for.

HotChilli
Super User
Super User

Change the order of the comparisons so that the more selective tests come before the less selective tests

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Dev Camp Session 30

Ted's Dev Camp - January 26, 2023

This session will provide guidance and teach campers the skills required to build Power BI reports that support multiple languages.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.