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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
01_RAF_01
Frequent Visitor

Text functions DAX

Hi Guys, 

 

im looking for a method to achieve the following. 

I have 2 columns. the first colomn contains names (name) and the other colums countries (country).

 

Now im looking to make another (calculated) column which searches the column "name" for people who starting with the letters m to z and have the "country" USA and FR. For those "hits" i want the tekst in the column to be "YES". For people who starting with other letters and have the "country" USA and FR. For those "hits" i want the tekst in the column to be "YESSS". Al other combo's i want "NO". 

 

Anyone familiair with tekstfunctions in DAX? 

1 ACCEPTED SOLUTION
pranit828
Community Champion
Community Champion

Hi @01_RAF_01 

can you please try

if(Table[Country] in {'USA','FR'}, 

            if(LEFT(Table[name],1) in {'m','n','o','p','q','r','s','t','u','v','w','x','y','z'},"YES","YESSS"),"NO")

       





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

View solution in original post

4 REPLIES 4
pranit828
Community Champion
Community Champion

Hi @01_RAF_01 

I am not aware of any such pattern matching functionality on DAX.

When I had to do a similar job , I used R code in Power Query editor.





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile
Samarth_18
Community Champion
Community Champion

Hi @01_RAF_01 ,

 

You can try below code:-

Column =
VAR startswith =
    LEFT ( Country_data[Name], 1 )
VAR result =
    IF (
        startswith
            IN { "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" },
        TRUE (),
        FALSE ()
    )
RETURN
    IF (
        result
            && Country_data[Country] IN { "USA", "FR" },
        "Yes",
        IF (
            result = FALSE ()
                && Country_data[Country] IN { "USA", "FR" },
            "YESSS",
            "NO"
        )
    )

Output:-

Samarth_18_0-1639666649433.png

 

Thanks,

Samarth

 

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

pranit828
Community Champion
Community Champion

Hi @01_RAF_01 

can you please try

if(Table[Country] in {'USA','FR'}, 

            if(LEFT(Table[name],1) in {'m','n','o','p','q','r','s','t','u','v','w','x','y','z'},"YES","YESSS"),"NO")

       





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

thanks @pranit828 it worked. I thought maybe there was a solution to look for the whole combination of letters without typing them all seperate. any idea if there is a solution for that?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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