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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

how to remove repetitive last name from full name using DAX

Hello!

I have a field with users' fullname, which some of them have repetitive last name, pls see some examples below. I need to clean this data using DAX. Please help me how to make them.

full name              expected full name

John Linx               John Linx

Marie Stb Stb        Marie Stb 

Louis T NX NX       Louis T NX

Jan S Med             Jan S Med

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

One of ways to achieve this is to use PATHITEM DAX function with "|".

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1674126771673.png

 

 

Expected full name CC = 
VAR _separate =
    SUBSTITUTE ( Data[Full Name], " ", "|" )
VAR _nameslist =
    UNION (
        { PATHITEM ( _separate, 1 ) },
        { PATHITEM ( _separate, 2 ) },
        { PATHITEM ( _separate, 3 ) },
        { PATHITEM ( _separate, 4 ) }
    )
VAR _summarizelist =
    SUMMARIZE ( _nameslist, [Value] )
RETURN
    CONCATENATEX ( _summarizelist, [Value], " " )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

3 REPLIES 3
jaweher899
Impactful Individual
Impactful Individual

You can use the DAX function SUBSTITUTE() to remove repetitive last names from full names in a column. Here is an example of how you can use this function to remove repetitive last names in a column called "Full Name":

  1. Create a new column called "Clean Full Name" in your data table.

  2. In the "Clean Full Name" column, use the DAX formula:

    =SUBSTITUTE(Full Name,[Full Name],RIGHT([Full Name],LEN([Full Name])-FIND(" ",Full Name,FIND(" ",Full Name)+1))," ")

  3. This formula uses the SUBSTITUTE function to replace the repetitive last name with a space character. The RIGHT function is used to extract the last name from the "Full Name" column, and the FIND function is used to locate the space character between the first and last name.

  4. Once the formula is in place, you can use the new "Clean Full Name" column in your dashboard or report instead of the original "Full Name" column.

Note: The above formula would work for the examples you've provided, but in case you have a different format of the full name, you might have to tweak the formula a bit.

Jihwan_Kim
Super User
Super User

Hi,

One of ways to achieve this is to use PATHITEM DAX function with "|".

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1674126771673.png

 

 

Expected full name CC = 
VAR _separate =
    SUBSTITUTE ( Data[Full Name], " ", "|" )
VAR _nameslist =
    UNION (
        { PATHITEM ( _separate, 1 ) },
        { PATHITEM ( _separate, 2 ) },
        { PATHITEM ( _separate, 3 ) },
        { PATHITEM ( _separate, 4 ) }
    )
VAR _summarizelist =
    SUMMARIZE ( _nameslist, [Value] )
RETURN
    CONCATENATEX ( _summarizelist, [Value], " " )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

Thank you! It is a very brilliant idea of using pathitem!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.