Forum Discussion

unnijoy's avatar
unnijoy
Post Prodigy
5 years ago
Solved

Extracting text before a delimiter

I have  a column ( Name & ID) that contain name and employee ID. i need to extract only the name using a dax.

 

for example the name is Mathew  V James (12345).

 

Now i need to get the text as Mathew V James.  

 

The Name & ID column is a calculated column. And i don't want to make any change in that column.  

 

Please help me with a measure that i need to use on a visula .

  • Hi unnijoy ,

     

    Does your Name & ID column contain data like "AA" without parentheses? If so, you will get an error when using the DAX provided by amitchandak . 

     

     

    Try the following formula:

     

    Name = 
    LEFT(
        'Table'[Name & ID],
        SEARCH(
            "(", 
            'Table'[Name & ID],
            ,
            LEN('Table'[Name & ID]) + 1
        ) - 1
    )

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

    Best Regards,
    Winniz

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

     

6 Replies

  • unnijoy , You need to have a new column for that. Best is split this in power query based on (

     

    In dax a new column

    left([name], search("(", [Name],,0)-1)

     

    • unnijoy's avatar
      unnijoy
      Post Prodigy

      hi amitchandak ,

       

      An argument of function 'LEFT' has the wrong data type or has an invalid value. this is the error message that i am getting. I check the column type. Its in Text.

      • v-kkf-msft's avatar
        v-kkf-msft
        Community Support

        Hi unnijoy ,

         

        Does your Name & ID column contain data like "AA" without parentheses? If so, you will get an error when using the DAX provided by amitchandak . 

         

         

        Try the following formula:

         

        Name = 
        LEFT(
            'Table'[Name & ID],
            SEARCH(
                "(", 
                'Table'[Name & ID],
                ,
                LEN('Table'[Name & ID]) + 1
            ) - 1
        )

         

        If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

        Best Regards,
        Winniz

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

         

  • Hi v-kkf-msft ,

     

    I'm Facing the same isssue if i try to fix FIND function then i usually get RIGHT function error . Here is the screenshot for your reference

     

    it's working fine without using variable but showing error once i'm trying to optimise this dax using variables