<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Dealing with duplicated values in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dealing-with-duplicated-values/m-p/4104478#M162881</link>
    <description>&lt;P&gt;I think I have a easy one for you guys.&lt;BR /&gt;We have a table with all suppliers, and in the past was not centralized who would setup them.&lt;BR /&gt;&lt;BR /&gt;With that being said we have the following scenario. (it is way more complext than that, but solving this would help)&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I want to show only the highlighted ones.....We may have suppliers duplicated with and without Country.&lt;BR /&gt;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)&lt;BR /&gt;In this scenario, Pen Supplier must be shown because there is no row with country for it.&lt;BR /&gt;&lt;BR /&gt;How do I do that?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Aug 2024 15:20:30 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-08-16T15:20:30Z</dc:date>
    <item>
      <title>Dealing with duplicated values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dealing-with-duplicated-values/m-p/4104478#M162881</link>
      <description>&lt;P&gt;I think I have a easy one for you guys.&lt;BR /&gt;We have a table with all suppliers, and in the past was not centralized who would setup them.&lt;BR /&gt;&lt;BR /&gt;With that being said we have the following scenario. (it is way more complext than that, but solving this would help)&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I want to show only the highlighted ones.....We may have suppliers duplicated with and without Country.&lt;BR /&gt;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)&lt;BR /&gt;In this scenario, Pen Supplier must be shown because there is no row with country for it.&lt;BR /&gt;&lt;BR /&gt;How do I do that?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 15:20:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dealing-with-duplicated-values/m-p/4104478#M162881</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-16T15:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with duplicated values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dealing-with-duplicated-values/m-p/4104596#M162888</link>
      <description>&lt;P&gt;Here is an example in M that will do what you have asked.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;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(_) &amp;gt; 1 then Table.SelectRows(_, each [Country] &amp;lt;&amp;gt; "-") else _}
        }
    ),
    #"Expanded _innerTable" = 
    Table.ExpandTableColumn(
        Custom1, 
        "_innerTable", 
        {"Country"}, 
        {"Country"}
    )
in
    #"Expanded _innerTable"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 15:51:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dealing-with-duplicated-values/m-p/4104596#M162888</guid>
      <dc:creator>jgeddes</dc:creator>
      <dc:date>2024-08-16T15:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with duplicated values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dealing-with-duplicated-values/m-p/4105903#M162936</link>
      <description>&lt;P&gt;Hi&amp;nbsp;jgeddes&amp;nbsp;,thanks for the quick reply, I'll add more.&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;The Table data is shown below:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;The solution using dax is as follows:&lt;/P&gt;
&lt;P&gt;Use the following DAX expression to create a table&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;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] &amp;lt;&amp;gt; "-" ),
                        [Country],
                        UNICHAR ( 10 )
                    )
                )
        ),
        [Supplier],
        [Country]
    )
&lt;/LI-CODE&gt;
&lt;P&gt;Final output&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Wenbin Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 01:46:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dealing-with-duplicated-values/m-p/4105903#M162936</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-19T01:46:36Z</dc:date>
    </item>
  </channel>
</rss>

