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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
JaoGabriel
Regular Visitor

Dealing with duplicated values

I think I have a easy one for you guys.
We have a table with all suppliers, and in the past was not centralized who would setup them.

With that being said we have the following scenario. (it is way more complext than that, but solving this would help)

JaoGabriel_0-1723821403638.png

I want to show only the highlighted ones.....We may have suppliers duplicated with and without Country.
For those duplicated ones, I want to show only the row with country, if there is no duplicates we show what we have (with or without Country)
In this scenario, Pen Supplier must be shown because there is no row with country for it.

How do I do that?

Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi jgeddes ,thanks for the quick reply, I'll add more.

Hi @JaoGabriel ,

The Table data is shown below:

vzhouwenmsft_0-1724031890807.png

The solution using dax is as follows:

Use the following DAX expression to create a table

Table 2 = 
VAR _table =
    SUMMARIZE (
        'Table',
        'Table'[Supplier],
        "CountOfSupplier", COUNTROWS ( 'Table' )
    )
RETURN
    SELECTCOLUMNS (
        ADDCOLUMNS (
            _table,
            "Country",
                IF (
                    [CountOfSupplier] = 1,
                    VAR _supplier = [Supplier]
                    RETURN
                        MAXX ( FILTER ( 'Table', 'Table'[Supplier] = _supplier ), [Country] ),
                    CONCATENATEX (
                        FILTER ( 'Table', 'Table'[Country] <> "-" ),
                        [Country],
                        UNICHAR ( 10 )
                    )
                )
        ),
        [Supplier],
        [Country]
    )

Final output

vzhouwenmsft_1-1724031949056.png

 

Best Regards,
Wenbin Zhou

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi jgeddes ,thanks for the quick reply, I'll add more.

Hi @JaoGabriel ,

The Table data is shown below:

vzhouwenmsft_0-1724031890807.png

The solution using dax is as follows:

Use the following DAX expression to create a table

Table 2 = 
VAR _table =
    SUMMARIZE (
        'Table',
        'Table'[Supplier],
        "CountOfSupplier", COUNTROWS ( 'Table' )
    )
RETURN
    SELECTCOLUMNS (
        ADDCOLUMNS (
            _table,
            "Country",
                IF (
                    [CountOfSupplier] = 1,
                    VAR _supplier = [Supplier]
                    RETURN
                        MAXX ( FILTER ( 'Table', 'Table'[Supplier] = _supplier ), [Country] ),
                    CONCATENATEX (
                        FILTER ( 'Table', 'Table'[Country] <> "-" ),
                        [Country],
                        UNICHAR ( 10 )
                    )
                )
        ),
        [Supplier],
        [Country]
    )

Final output

vzhouwenmsft_1-1724031949056.png

 

Best Regards,
Wenbin Zhou

 

jgeddes
Super User
Super User

Here is an example in M that will do what you have asked.

jgeddes_0-1723823466319.pngjgeddes_1-1723823478082.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkgsSC1SCC4tKMjJTC1S0lHSVYrVwSLsVJRYlZkDkUvNw6IhNS85MwdZPDTYUSk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Supplier = _t, Country = _t]),
    #"Changed Type" = 
    Table.TransformColumnTypes(
        Source,
        {
            {"Supplier", type text}, 
            {"Country", type text}
        }
    ),
    #"Grouped Rows" = 
    Table.Group(
        #"Changed Type", 
        {"Supplier"}, 
        {
            {"_innerTable", each Table.SelectColumns(_, "Country"), type table [Country=nullable text]}
        }
    ),
    Custom1 = 
    Table.TransformColumns(
        #"Grouped Rows", 
        {
            {"_innerTable", each if Table.RowCount(_) > 1 then Table.SelectRows(_, each [Country] <> "-") else _}
        }
    ),
    #"Expanded _innerTable" = 
    Table.ExpandTableColumn(
        Custom1, 
        "_innerTable", 
        {"Country"}, 
        {"Country"}
    )
in
    #"Expanded _innerTable"

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.