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
Anonymous
Not applicable

How to find number of the character reading right to left ?

I want to find the starting position of one text string within another text string, reading right to left.

Below is the value from which I want retrieve the color name (Silver).

Contoso Optical Wheel OEM PS/2 Mouse E60 Silver

I tried using Search function but unfortunatly it did'nt work for me because it starts reading the text from leff to right.

RIGHT([Product Name],SEARCH(" ",[Product Name],1,BLANK()))

Please suggest a function or approch using which I can get the desired result.

1 ACCEPTED SOLUTION

Sorry, I misread the question! It's a bit more tricky. I got the below to work. It depends on identifying the position of the last space in the string before using the first method again

 

 

Column =
VAR __NumberOfSpaces =
LEN('Table'[Product Name])-len(SUBSTITUTE('Table'[Product Name]," ","")) //Find how many spaces are in the string
return
RIGHT( //The same basic structure: RIGHT(), LEN() ans SEARCH()
    [Product Name],
    LEN([Product Name]) - 
    SEARCH("@", //Search for "@" (any character that you
                //choose that do not exist in the strings beforehand)
        SUBSTITUTE('Table'[Product Name]," ","@",__NumberOfSpaces) 
            //Use SUBSTITUTE() to replace space with "@" only on 
            //the last (__NumberOfSpaces) occurence of space.
        ,1,
        BLANK()
    )
)

 

TomasAndersson_0-1671439671338.png

 

View solution in original post

5 REPLIES 5
TomasAndersson
Solution Sage
Solution Sage

Hi!

You can combine LEN() and SEARCH() to mimic right-to-left reading.

 

I haven't double-checked this code, but something like below should work:

RIGHT([Product Name],LEN([Product Name])-(SEARCH(" ",[Product Name],1,BLANK()))

Let me know if it doesn't and I'll take a closer look!

Anonymous
Not applicable

Hi @TomasAndersson Unfortunatly, It didn't work. 

Sorry, I misread the question! It's a bit more tricky. I got the below to work. It depends on identifying the position of the last space in the string before using the first method again

 

 

Column =
VAR __NumberOfSpaces =
LEN('Table'[Product Name])-len(SUBSTITUTE('Table'[Product Name]," ","")) //Find how many spaces are in the string
return
RIGHT( //The same basic structure: RIGHT(), LEN() ans SEARCH()
    [Product Name],
    LEN([Product Name]) - 
    SEARCH("@", //Search for "@" (any character that you
                //choose that do not exist in the strings beforehand)
        SUBSTITUTE('Table'[Product Name]," ","@",__NumberOfSpaces) 
            //Use SUBSTITUTE() to replace space with "@" only on 
            //the last (__NumberOfSpaces) occurence of space.
        ,1,
        BLANK()
    )
)

 

TomasAndersson_0-1671439671338.png

 

Anonymous
Not applicable

@TomasAndersson Thank you so much ! It worked 

There also seems to be a working method using PowerQuery: 
Solved: Search from right to left - Microsoft Power BI Community

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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