<?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: Group table in terms of date column and specific value of another column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1926748#M41793</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use Group By in Power Query. See step GroupRows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
  Source = OriginalTable,
  GroupByDate = Table.Group(
    Source,
    {"Date"},
    {{"res", each if List.PositionOf([Main column], "Main Category") &amp;lt;&amp;gt; - 1 then _ else null}}
  ),
  ExpandRows =
    let
      cols = Table.ColumnNames(Source)
    in
      Table.ExpandTableColumn(
        Table.SelectRows(Table.RemoveColumns(GroupByDate, "Date"), each not ([res] is null)),
        "res",
        cols,
        cols
      ),
  ChangeType = Table.TransformColumnTypes(
    ExpandRows,
    {{"ID", Int64.Type}, {"Date", type date}, {"Price", Int64.Type}}
  ),
  GroupRows = Table.Group(
    ChangeType,
    {"Date", "category_id"},
    {{"Sum Price", each List.Sum([Price]), type number}}
  )
in
  GroupRows&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Jun 2021 23:00:30 GMT</pubDate>
    <dc:creator>DataInsights</dc:creator>
    <dc:date>2021-06-28T23:00:30Z</dc:date>
    <item>
      <title>Group table in terms of date column and specific value of another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1923947#M41724</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem which sounds so easy but as I'm a newbie I can't manage it and need your expertise to help me please:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a sample you can have a look at the table below:&lt;/P&gt;&lt;P&gt;I need to remove all the rows which have not Main Category value on their date (in this example I should remove rows 9,10,11), The main category value here is the beginning point for my process per day and if it does not exist in a day, I should remove all the other records on that specific date or ignore them&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you please let me know how can I make a DAX code or M-query to fix it? as my data are thousands or millions, needs to have the fastest one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jun 2021 14:16:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1923947#M41724</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-06-27T14:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Group table in terms of date column and specific value of another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1924018#M41726</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this solution in Power Query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Create table MainCategoryDates, consisting of distinct dates for "Main Category" rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = OriginalTable,
    FilterRows = Table.SelectRows(Source, each ([Main column] = "Main Category")),
    RemoveColumns = Table.SelectColumns(FilterRows,{"Date"}),
    RemoveDuplicates = Table.Distinct(RemoveColumns)
in
    RemoveDuplicates&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Merge table MainCategoryDates with the data table using an inner join on the Date column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.NestedJoin(OriginalTable, {"Date"}, MainCategoryDates, {"Date"}, "MainCategoryDates", JoinKind.Inner),
    RemoveColumns = Table.RemoveColumns(Source,{"MainCategoryDates"})
in
    RemoveColumns&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jun 2021 17:21:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1924018#M41726</guid>
      <dc:creator>DataInsights</dc:creator>
      <dc:date>2021-06-27T17:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Group table in terms of date column and specific value of another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1924027#M41727</link>
      <description>&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8k3MzFNwTixJTc8vqlTSUTIyMDLUNTDTNTBUitWJVkovKlAwxC5shCmMyzBDI7guY+zCJsjCFnBhU+zCZmjCsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Main Column" = _t, Date = _t]),
    #"Grouped by Date" = Table.Group(Source, {"Date"}, {{"res", each if List.PositionOf([Main Column], "Main Category")&amp;lt;&amp;gt;-1 then _ else null}}),
    #"Expanded Rows" = let cols=Table.ColumnNames(Source) in Table.ExpandTableColumn(Table.SelectRows(Table.RemoveColumns(#"Grouped by Date", "Date"), each not([res] is null)), "res", cols, cols)
in
    #"Expanded Rows"&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jun 2021 18:08:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1924027#M41727</guid>
      <dc:creator>CNENFRNL</dc:creator>
      <dc:date>2021-06-27T18:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: Group table in terms of date column and specific value of another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1924679#M41743</link>
      <description>&lt;P&gt;Many thanks, it works well &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 06:12:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1924679#M41743</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-06-28T06:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Group table in terms of date column and specific value of another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1924680#M41744</link>
      <description>&lt;P&gt;Thank you, it works well for both solutions &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 06:13:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1924680#M41744</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-06-28T06:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Group table in terms of date column and specific value of another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1925921#M41763</link>
      <description>&lt;P&gt;May I ask if I want to add another column to have the condition based on that as well, how can I extend this query?&amp;nbsp; I have another column called&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;category_id&lt;/EM&gt;&lt;/STRONG&gt;, and I want to check if we have the&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Main category&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;check the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;category_id&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;of all these group1, group2, ... and if their&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;category_ids&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;is the same as the&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Main category&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;then accumulate prices of them:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For the above example if group 1, group 2 has the same category_id as the Main category,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I need to sum up for Feb 12th prices of Main category + group 1 + group 2 = 1290+340+367&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 13:38:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1925921#M41763</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-06-28T13:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: Group table in terms of date column and specific value of another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1926748#M41793</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use Group By in Power Query. See step GroupRows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
  Source = OriginalTable,
  GroupByDate = Table.Group(
    Source,
    {"Date"},
    {{"res", each if List.PositionOf([Main column], "Main Category") &amp;lt;&amp;gt; - 1 then _ else null}}
  ),
  ExpandRows =
    let
      cols = Table.ColumnNames(Source)
    in
      Table.ExpandTableColumn(
        Table.SelectRows(Table.RemoveColumns(GroupByDate, "Date"), each not ([res] is null)),
        "res",
        cols,
        cols
      ),
  ChangeType = Table.TransformColumnTypes(
    ExpandRows,
    {{"ID", Int64.Type}, {"Date", type date}, {"Price", Int64.Type}}
  ),
  GroupRows = Table.Group(
    ChangeType,
    {"Date", "category_id"},
    {{"Sum Price", each List.Sum([Price]), type number}}
  )
in
  GroupRows&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 23:00:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1926748#M41793</guid>
      <dc:creator>DataInsights</dc:creator>
      <dc:date>2021-06-28T23:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Group table in terms of date column and specific value of another column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1928232#M41841</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="207275" data-lia-user-login="DataInsights" class="lia-mention lia-mention-user"&gt;DataInsights&lt;/a&gt;&amp;nbsp; &amp;nbsp;thanks a lot, it works well and now I learned how can I group-by a table with one or more conditions ... that was what exactly I wanted &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 12:45:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Group-table-in-terms-of-date-column-and-specific-value-of/m-p/1928232#M41841</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-06-29T12:45:50Z</dc:date>
    </item>
  </channel>
</rss>

