<?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 Re: Make rows in new table based on column values in existing table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Make-rows-in-new-table-based-on-column-values-in-existing-table/m-p/3827931#M149671</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please try&lt;/P&gt;
&lt;P&gt;CustomerProductCodes =&lt;BR /&gt;DISTINCT (&lt;BR /&gt;GENERATE (&lt;BR /&gt;SUMMARIZE (&lt;BR /&gt;CALCULATETABLE ( 'CustomerProduct' ),&lt;BR /&gt;'CustomerProduct'[CustomerID],&lt;BR /&gt;'CustomerProduct'[Toys],&lt;BR /&gt;'CustomerProduct'[Shoes],&lt;BR /&gt;'CustomerProduct'[Food],&lt;BR /&gt;'CustomerProduct'[Dresses]&lt;BR /&gt;),&lt;BR /&gt;UNION (&lt;BR /&gt;SELECTCOLUMNS (&lt;BR /&gt;{ 'CustomerProduct'[Toys] },&lt;BR /&gt;"ProductCodes", IF ( [Toys] = "T", "T" )&lt;BR /&gt;),&lt;BR /&gt;SELECTCOLUMNS (&lt;BR /&gt;{ 'CustomerProduct'[Shoes] },&lt;BR /&gt;"ProductCodes", IF ( [Shoes] = "S", "S" )&lt;BR /&gt;),&lt;BR /&gt;SELECTCOLUMNS (&lt;BR /&gt;{ 'CustomerProduct'[Food] },&lt;BR /&gt;"ProductCodes", IF ( [Food] = "F", "F" )&lt;BR /&gt;),&lt;BR /&gt;SELECTCOLUMNS (&lt;BR /&gt;{ 'CustomerProduct'[Dresses] },&lt;BR /&gt;"ProductCodes", IF ( [Dresses] = "D", "D" )&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;</description>
    <pubDate>Wed, 10 Apr 2024 16:25:13 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2024-04-10T16:25:13Z</dc:date>
    <item>
      <title>Make rows in new table based on column values in existing table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Make-rows-in-new-table-based-on-column-values-in-existing-table/m-p/3827504#M149644</link>
      <description>&lt;P&gt;I have this table definition in Power BI:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;CustomerProductCodes = DISTINCT(&lt;/P&gt;&lt;P&gt;&amp;nbsp; SELECTCOLUMNS(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; CALCULATETABLE('CustomerProduct')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ,"CustomerID"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ,[CustomerID]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ,"ProductCodes"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ,if([Toys]="T","T,","")&amp;amp;if([Shoes]="S","S,","")&amp;amp;if([Food]="F","F,","")&amp;amp;if([Dresses]="D","D,","")&lt;BR /&gt;&amp;nbsp; )&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will be like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;CustomerID&lt;/TD&gt;&lt;TD&gt;ProductCodes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;T,F,D,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;TD&gt;F,D,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;87&lt;/TD&gt;&lt;TD&gt;S,F,D&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't want the codes in the same column but each code on it's own row like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;CustomerID&lt;/TD&gt;&lt;TD&gt;ProductCodes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;T&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;87&lt;/TD&gt;&lt;TD&gt;S&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;87&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;87&lt;/TD&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I do this in defining the table?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2024 13:06:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Make-rows-in-new-table-based-on-column-values-in-existing-table/m-p/3827504#M149644</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-10T13:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Make rows in new table based on column values in existing table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Make-rows-in-new-table-based-on-column-values-in-existing-table/m-p/3827931#M149671</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please try&lt;/P&gt;
&lt;P&gt;CustomerProductCodes =&lt;BR /&gt;DISTINCT (&lt;BR /&gt;GENERATE (&lt;BR /&gt;SUMMARIZE (&lt;BR /&gt;CALCULATETABLE ( 'CustomerProduct' ),&lt;BR /&gt;'CustomerProduct'[CustomerID],&lt;BR /&gt;'CustomerProduct'[Toys],&lt;BR /&gt;'CustomerProduct'[Shoes],&lt;BR /&gt;'CustomerProduct'[Food],&lt;BR /&gt;'CustomerProduct'[Dresses]&lt;BR /&gt;),&lt;BR /&gt;UNION (&lt;BR /&gt;SELECTCOLUMNS (&lt;BR /&gt;{ 'CustomerProduct'[Toys] },&lt;BR /&gt;"ProductCodes", IF ( [Toys] = "T", "T" )&lt;BR /&gt;),&lt;BR /&gt;SELECTCOLUMNS (&lt;BR /&gt;{ 'CustomerProduct'[Shoes] },&lt;BR /&gt;"ProductCodes", IF ( [Shoes] = "S", "S" )&lt;BR /&gt;),&lt;BR /&gt;SELECTCOLUMNS (&lt;BR /&gt;{ 'CustomerProduct'[Food] },&lt;BR /&gt;"ProductCodes", IF ( [Food] = "F", "F" )&lt;BR /&gt;),&lt;BR /&gt;SELECTCOLUMNS (&lt;BR /&gt;{ 'CustomerProduct'[Dresses] },&lt;BR /&gt;"ProductCodes", IF ( [Dresses] = "D", "D" )&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2024 16:25:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Make-rows-in-new-table-based-on-column-values-in-existing-table/m-p/3827931#M149671</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2024-04-10T16:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Make rows in new table based on column values in existing table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Make-rows-in-new-table-based-on-column-values-in-existing-table/m-p/3830530#M149763</link>
      <description>&lt;P&gt;I forgot that in CustomerProduct I have a column with YearMonth. The Customers buy several things in different months.&lt;/P&gt;&lt;P&gt;It will be like this when I add YearMonth in spec:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;YearMonth&lt;/TD&gt;&lt;TD&gt;CustomerID&lt;/TD&gt;&lt;TD&gt;ProductCodes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;202401&lt;/TD&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;T,F,D,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;202401&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;TD&gt;F,D,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;202401&lt;/TD&gt;&lt;TD&gt;87&lt;/TD&gt;&lt;TD&gt;S,F,D,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;202402&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;TD&gt;D,T,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;202402&lt;/TD&gt;&lt;TD&gt;87&lt;/TD&gt;&lt;TD&gt;F,D,&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want YearMonth in the&amp;nbsp;&lt;SPAN&gt;CustomerProductCodes table, too. How do I do that?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 10:31:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Make-rows-in-new-table-based-on-column-values-in-existing-table/m-p/3830530#M149763</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-11T10:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Make rows in new table based on column values in existing table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Make-rows-in-new-table-based-on-column-values-in-existing-table/m-p/3837273#M150024</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;,thanks for the quick reply, I'll add further.&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Regarding your question, the table data are as follows.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Try to modify your DAX expression.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Table = DISTINCT(
    SELECTCOLUMNS(
    CALCULATETABLE('CustomerProduct'),
    "YearMonth",[YearMonth],
    "CustomerID",[CusTomerID],
    "ProductCodes",if([Toys]="T","T,","")&amp;amp;if([Shoes]="S","S,","")&amp;amp;if([Food]="F","F,","")&amp;amp;if([Dresses]="D","D,","")
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;You can also use Power Query if you are trying to split.Copy the table data to Excel, use 'Get data' and click 'Transform data'.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Details can be found in the following articles.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/power-query/split-columns-delimiter" target="_blank"&gt;Split columns by delimiter - Power Query | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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 = FILTER('Sheet3','Sheet3'[ProductCodes] &amp;lt;&amp;gt; BLANK())&lt;/LI-CODE&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;BR /&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2024 07:15:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Make-rows-in-new-table-based-on-column-values-in-existing-table/m-p/3837273#M150024</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-15T07:15:46Z</dc:date>
    </item>
  </channel>
</rss>

