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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Compare Names between two columns and return difference

I have a dataset that contains users in and all users. I want to be able to compare these columns and return a column that shows users that are in 

 

dandan123456_1-1636719600666.png

 

Expected Result:

 

dandan123456_2-1636719645061.png

 

 

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@Anonymous  solely with a dax measure.

 

_missingValues =
VAR _1 =
    ADDCOLUMNS ( 'Table', "_allUsers", SUBSTITUTE ( 'Table'[All Users], ",", "|" ) )
VAR _2 =
    GENERATE (
        _1,
        ADDCOLUMNS (
            GENERATESERIES ( 1, PATHLENGTH ( [_allUsers] ) ),
            "Words", PATHITEM ( [_allUsers], [Value], TEXT )
        )
    )
RETURN
    CONCATENATEX (
        FILTER (
            _2,
            [Users off] <> [Words]
                && CONTAINSSTRING ( [Users off], [Words] ) = FALSE ()
        ),
        [Words],
        ",",
        [Words]
    )

 

 

smpa01_0-1637030348389.png

 

And a calculated column

 

smpa01_1-1637030772601.png

 

Column = 
VAR _1 =
    
        ADDCOLUMNS ( 'Table', "_allUsers", SUBSTITUTE ( 'Table'[All Users], ",", "|" ) )
        
VAR _2 =
    GENERATE (
        _1,
        ADDCOLUMNS (
            GENERATESERIES ( 1, PATHLENGTH ( [_allUsers] ) ),
            "Words", PATHITEM ( [_allUsers], [Value], TEXT )
        )
    )
RETURN
    CONCATENATEX (
        FILTER (
            _2,
            [Users off] <> [Words]
                && CONTAINSSTRING ( [Users off], [Words] ) = FALSE ()&&'Table'[Index]=EARLIER([Index])
        ),
        [Words],
        ",",
        [Words]
    )

PBIX is attached

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

5 REPLIES 5
smpa01
Super User
Super User

@Anonymous  solely with a dax measure.

 

_missingValues =
VAR _1 =
    ADDCOLUMNS ( 'Table', "_allUsers", SUBSTITUTE ( 'Table'[All Users], ",", "|" ) )
VAR _2 =
    GENERATE (
        _1,
        ADDCOLUMNS (
            GENERATESERIES ( 1, PATHLENGTH ( [_allUsers] ) ),
            "Words", PATHITEM ( [_allUsers], [Value], TEXT )
        )
    )
RETURN
    CONCATENATEX (
        FILTER (
            _2,
            [Users off] <> [Words]
                && CONTAINSSTRING ( [Users off], [Words] ) = FALSE ()
        ),
        [Words],
        ",",
        [Words]
    )

 

 

smpa01_0-1637030348389.png

 

And a calculated column

 

smpa01_1-1637030772601.png

 

Column = 
VAR _1 =
    
        ADDCOLUMNS ( 'Table', "_allUsers", SUBSTITUTE ( 'Table'[All Users], ",", "|" ) )
        
VAR _2 =
    GENERATE (
        _1,
        ADDCOLUMNS (
            GENERATESERIES ( 1, PATHLENGTH ( [_allUsers] ) ),
            "Words", PATHITEM ( [_allUsers], [Value], TEXT )
        )
    )
RETURN
    CONCATENATEX (
        FILTER (
            _2,
            [Users off] <> [Words]
                && CONTAINSSTRING ( [Users off], [Words] ) = FALSE ()&&'Table'[Index]=EARLIER([Index])
        ),
        [Words],
        ",",
        [Words]
    )

PBIX is attached

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@Anonymous did you try the above?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
amitchandak
Super User
Super User

@Anonymous , A new column in power query

 

List.RemoveItems(Text.Split([All User],","),Text.Split([All User],","))

 

 

Anonymous
Not applicable

Hi @amitchandak  sorry my current columns are via a DAX Column. Therefore this would need to be done in DAX

Hi @Anonymous ,

Agree with @ amitchandak, it is better to use Power Query to achieve it because the string comparison is strictly defined in DAX and split columns is too complex.

 

Since the two user columns have been created by DAX, you can consider using the simliar logic to create them in Power Query first and refer this simliar thread to compare string columns to find the difference in Power Query:

Comparing String in two columns for differences 

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.