Forum Discussion

JK-1's avatar
JK-1
Helper II
1 year ago
Solved

DAX to de-duplicate text string?

Would it be possible to get DAX de-duplicating a text string? In the example below - or any suggestions on alternate ways, but still using DAX  🙂  thanks in advance

 

AddressAreaDistributionstring = CONCATENATEX(FILTER(('Table'),'Table'[Address]=EARLIER('Table'[Address])),'Table'[Area],"; ")would then like it de-duplicated -- but wondered if DAX could facilitate?
George Street1st FloorZone 31st Floor; 1st Floor; 2nd Floor1st Floor; 2nd Floor
George Street2nd FloorZone 11st Floor; 1st Floor; 2nd Floor1st Floor; 2nd Floor
George Street1st FloorZone 51st Floor; 1st Floor; 2nd Floor1st Floor; 2nd Floor
Lime WalkBasementZone 7Basement; BasementBasement
Lime WalkBasementZone 4Basement; BasementBasement
Hope AvenueBasementZone 21st Floor; 1st Floor; BasementBasement; 1st Floor
Hope Avenue1st FloorZone 81st Floor; 1st Floor; BasementBasement; 1st Floor
Hope Avenue1st FloorZone 51st Floor; 1st Floor; BasementBasement; 1st Floor
Market Square2nd FloorZone 62nd Floor2nd Floor
  • Try this.DeDuplicatedString =

    CALCULATE(

        CONCATENATEX(

            VALUES('Table'[Area]), -- <-- this removes duplicates

            'Table'[Area],

            "; ",

            'Table'[Area]

        ),

        ALLEXCEPT('Table', 'Table'[Addr

    ess])

    )

4 Replies

  • Chanty4u's avatar
    Chanty4u
    Frequent Visitor

    Try this.DeDuplicatedString =

    CALCULATE(

        CONCATENATEX(

            VALUES('Table'[Area]), -- <-- this removes duplicates

            'Table'[Area],

            "; ",

            'Table'[Area]

        ),

        ALLEXCEPT('Table', 'Table'[Addr

    ess])

    )

  • JJ_3's avatar
    JJ_3
    Frequent Visitor

    Chanty4u is right. You can also only use

    String =

    CONCATENATEX(

    VALUES('Table'[Area]), -- <-- this removes duplicates

    'Table'[Area],

    "; ",

    'Table'[Area]


    If u only us the adres
  • Hi JK-1 please try this calculated column

     

    DeDuplicatedAreas =
    VAR CurrentAddress = AddressAreas[Address]
    VAR DistinctAreas =
        CALCULATETABLE(
            VALUES(AddressAreas[Area]),
            FILTER(
                ALL(AddressAreas),
                AddressAreas[Address] = CurrentAddress
            )
        )
    RETURN
        CONCATENATEX(
            DistinctAreas,
            AddressAreas[Area],
            "; ",
            AddressAreas[Area], ASC
        )