<?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 Count Rows by Group with Filter in Power Query</title>
    <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2084498#M61395</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been trying solve this formula but i can't. I would appreciate if someone can help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my DDBB:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Date / ID / Type of order&lt;/P&gt;&lt;P&gt;Row 1:&amp;nbsp;2021-09-16 22:53:40 /&amp;nbsp;700570502001694405 / Buy&lt;BR /&gt;Row 2:&amp;nbsp;2021-09-15 21:53:40 /&amp;nbsp;700570502001692141 / Sell&lt;BR /&gt;Row 3:&amp;nbsp;2021-09-16 09:23:40 /&amp;nbsp;700570502001694405 / Buy&lt;BR /&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to get a table to see how many times the buyers make one purchase?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this structure:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 times&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2 times&lt;/P&gt;&lt;P&gt;3-5 times&lt;/P&gt;&lt;P&gt;6+ times&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this formula only with the first condition, to try if the formula is ok, but no...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nº of Purchases =&lt;BR /&gt;VAR BuyID = CALCULATE(&lt;BR /&gt;COUNT(DDBB[ID]),&lt;BR /&gt;FILTER(DDBB,DDBB[Type of order]="Buy")&lt;BR /&gt;)&lt;BR /&gt;VAR NPurchase = SWITCH(&lt;BR /&gt;TRUE(),&lt;BR /&gt;BuyID=1, "1",&lt;BR /&gt;"Test"&lt;BR /&gt;)&lt;BR /&gt;RETURN NPurchase&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The result is that all the buy rows are counted but I can't create the different groups. What is my mistake?&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;&lt;P&gt;cheers!&lt;/P&gt;</description>
    <pubDate>Sun, 19 Sep 2021 12:44:37 GMT</pubDate>
    <dc:creator>modwonka</dc:creator>
    <dc:date>2021-09-19T12:44:37Z</dc:date>
    <item>
      <title>Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2084498#M61395</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been trying solve this formula but i can't. I would appreciate if someone can help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my DDBB:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Date / ID / Type of order&lt;/P&gt;&lt;P&gt;Row 1:&amp;nbsp;2021-09-16 22:53:40 /&amp;nbsp;700570502001694405 / Buy&lt;BR /&gt;Row 2:&amp;nbsp;2021-09-15 21:53:40 /&amp;nbsp;700570502001692141 / Sell&lt;BR /&gt;Row 3:&amp;nbsp;2021-09-16 09:23:40 /&amp;nbsp;700570502001694405 / Buy&lt;BR /&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to get a table to see how many times the buyers make one purchase?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this structure:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 times&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2 times&lt;/P&gt;&lt;P&gt;3-5 times&lt;/P&gt;&lt;P&gt;6+ times&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this formula only with the first condition, to try if the formula is ok, but no...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nº of Purchases =&lt;BR /&gt;VAR BuyID = CALCULATE(&lt;BR /&gt;COUNT(DDBB[ID]),&lt;BR /&gt;FILTER(DDBB,DDBB[Type of order]="Buy")&lt;BR /&gt;)&lt;BR /&gt;VAR NPurchase = SWITCH(&lt;BR /&gt;TRUE(),&lt;BR /&gt;BuyID=1, "1",&lt;BR /&gt;"Test"&lt;BR /&gt;)&lt;BR /&gt;RETURN NPurchase&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The result is that all the buy rows are counted but I can't create the different groups. What is my mistake?&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;&lt;P&gt;cheers!&lt;/P&gt;</description>
      <pubDate>Sun, 19 Sep 2021 12:44:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2084498#M61395</guid>
      <dc:creator>modwonka</dc:creator>
      <dc:date>2021-09-19T12:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2084515#M61398</link>
      <description>&lt;P&gt;Hello - this is how you can achieve the desired outcome with Power Query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Group the purchases by ID, creating an aggregated column that counts the number of purchases (Type of Order = Buy).&lt;/LI&gt;&lt;LI&gt;Create a mapping table that has the counts and labels as they should be applied.&lt;/LI&gt;&lt;LI&gt;Merge the two tables (result below).&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;RESULT&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MAPPING TABLE (named Count Labels)&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MAPPING TABLE (Count Labels) SCRIPT&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlDSUTJQCMnMTS1WitWJVjIE8g3BfDDXCMg1QpI2BvKNdU2RREwwRExRRWIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Count = _t, Label = _t]),
    ChangeType = Table.TransformColumnTypes(Source,{{"Count", Int64.Type}})
in
    ChangeType&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RESULT SCRIPT&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstQ3NNM3MjAyVDAysjI1VtJRMjcwMDU3MDUwMjAwNLM0MTEwBQo6lVYqxeqAlZtClRtiU25kaGIIFAxOzcmBqYcab2llhN/0WAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, ID = _t, #"Type of Order" = _t]),
    ChangeType = Table.TransformColumnTypes(#"Grouped Rows",{{"Date", type datetime}, {"ID", type text}, {"Type of Order", type text}}),
    Grouped = Table.Group(
        Source, 
        {"ID"}, 
        {
            { "Count of Purchases", each List.Count ( List.Select ( _[Type of Order], each _ = "Buy" ) ) }           
        }
    ),
    ChangeTypeCount = Table.TransformColumnTypes(Grouped,{{"Count of Purchases", Int64.Type}}),
    Merge = Table.NestedJoin(ChangeTypeCount, {"Count of Purchases"}, #"Count Labels", {"Count"}, "Count Labels", JoinKind.LeftOuter),
    Expand = Table.ExpandTableColumn(Merge, "Count Labels", {"Label"}, {"Label"})
in
    Expand&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 19 Sep 2021 13:12:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2084515#M61398</guid>
      <dc:creator>jennratten</dc:creator>
      <dc:date>2021-09-19T13:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2089980#M61567</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="322392" data-lia-user-login="modwonka" class="lia-mention lia-mention-user"&gt;modwonka&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;With the DAX formula, you can create a calculated column to group first:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;No. of Purchases = 
VAR BuyID =
    CALCULATE (
        COUNT ( 'Table'[ID] ),
        FILTER (
            'Table',
            'Table'[Tyoe of order] = "Buy"
                &amp;amp;&amp;amp; 'Table'[ID] = EARLIER ( 'Table'[ID] )
        )
    )
VAR NPurchase =
    SWITCH (
        TRUE (),
        BuyID = 1, "1 times",
        BuyID = 2, "2 times",
        BuyID &amp;gt;= 3
            &amp;amp;&amp;amp; BuyID &amp;lt;= 5, "3-5 tiems",
        BuyID &amp;gt;= 6, "6+ times"
    )
RETURN
    NPurchase&lt;/LI-CODE&gt;
&lt;P&gt;Create a measure to count:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count = 
COUNTX ( SUMMARIZE ( 'Table', 'Table'[ID], 'Table'[No. of Purchases] ), [ID] )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Yingjie Li&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Sep 2021 01:30:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2089980#M61567</guid>
      <dc:creator>v-yingjl</dc:creator>
      <dc:date>2021-09-22T01:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2098169#M61844</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="199176" data-lia-user-login="v-yingjl" class="lia-mention lia-mention-user"&gt;v-yingjl&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the idea! It seems it works but I have one problem...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I set the first part in a new PowerBi only with the data of one day, everything works well. When I add more days and I tried to filter to see how the formula works in that period... it doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You imagine I wanna see how was the nº of purchase in one specific date, could I do it with some change in the formula?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 25 Sep 2021 21:12:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2098169#M61844</guid>
      <dc:creator>modwonka</dc:creator>
      <dc:date>2021-09-25T21:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2098900#M61874</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="322392" data-lia-user-login="modwonka" class="lia-mention lia-mention-user"&gt;modwonka&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Modify the first formula variable like this and it should work to calculate for each day:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;VAR BuyID =
    CALCULATE (
        COUNT ( 'Table'[ID] ),
        FILTER (
            'Table',
            'Table'[Tyoe of order] = "Buy"
                &amp;amp;&amp;amp; 'Table'[ID] = EARLIER ( 'Table'[ID] )
                &amp;amp;&amp;amp; 'Table'[Date] = EARLER ('Table'[Date])
        )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Yingjie Li&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 00:59:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2098900#M61874</guid>
      <dc:creator>v-yingjl</dc:creator>
      <dc:date>2021-09-27T00:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2100035#M61904</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="199176" data-lia-user-login="v-yingjl" class="lia-mention lia-mention-user"&gt;v-yingjl&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks again!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think we're close to the solution. With that change, if I filter the data one day only, everything works. But if I try to open the selection to two or more days, the results are not ok... It doesn't count well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know why can it be happening?&lt;/P&gt;&lt;P&gt;Maybe we have to filter the data between two dates in the formula?&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 09:18:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2100035#M61904</guid>
      <dc:creator>modwonka</dc:creator>
      <dc:date>2021-09-27T09:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2101529#M61942</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="322392" data-lia-user-login="modwonka" class="lia-mention lia-mention-user"&gt;modwonka&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Oh I forget to change the count formula:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count = COUNT('Table'[ID])
// COUNTX ( SUMMARIZE ( 'Table', 'Table'[ID], 'Table'[No. of Purchases] ), [ID] )&lt;/LI-CODE&gt;
&lt;P&gt;Use SUMMARIZE() would distinct the table for the specific columns, now it should be correct with the filter.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Yingjie Li&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 01:22:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2101529#M61942</guid>
      <dc:creator>v-yingjl</dc:creator>
      <dc:date>2021-09-28T01:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2102356#M61974</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="199176" data-lia-user-login="v-yingjl" class="lia-mention lia-mention-user"&gt;v-yingjl&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks again for your help. With that change, it's not ok. Maybe I explained wrong my idea...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanna see how is the buying frequency (nº of purchase) of the customers (ID) in a certain time.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I copy a table with the result of your fake data. You can see there are:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;only 1 buyer with one transaction.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;1 with 2 transactions.&lt;/LI&gt;&lt;LI&gt;1 buyer with 3 transactions.&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;2 buyers with 5 transactions.&lt;/LI&gt;&lt;LI&gt;1 buyer with +6 transactions.&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I wanna see that nº of buyers per transaction with a range of dates. Did I explain correctly?&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 08:14:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2102356#M61974</guid>
      <dc:creator>modwonka</dc:creator>
      <dc:date>2021-09-28T08:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2102399#M61976</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="322392" data-lia-user-login="modwonka" class="lia-mention lia-mention-user"&gt;modwonka&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;So 3-5 times should be counted sepratly, right?&lt;/P&gt;
&lt;P&gt;The column should be:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;No. of Purchases = 
VAR BuyID =
    CALCULATE (
        COUNT ( 'Table'[ID] ),
        FILTER (
            'Table',
            'Table'[Tyoe of order] = "Buy"
                &amp;amp;&amp;amp; 'Table'[ID] = EARLIER ( 'Table'[ID] )
        )
    )
VAR NPurchase =
    SWITCH (
        TRUE (),
        BuyID = 1, "1 times",
        BuyID = 2, "2 times",
        BuyID = 3, "3 times",
        BuyID = 4, "4 times",
        BuyID = 5, "5 times",
        BuyID &amp;gt;= 6, "6+ times"
    )
RETURN
    NPurchase&lt;/LI-CODE&gt;
&lt;P&gt;Count measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count = COUNTX ( SUMMARIZE ( 'Table', 'Table'[ID], 'Table'[No. of Purchases] ), [ID] )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Yingjie Li&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 08:31:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2102399#M61976</guid>
      <dc:creator>v-yingjl</dc:creator>
      <dc:date>2021-09-28T08:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2102535#M61982</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="199176" data-lia-user-login="v-yingjl" class="lia-mention lia-mention-user"&gt;v-yingjl&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this change, if you see the ID "5.000" one day (15th), it's ok. +6 times. But if you select day 16th, ID 5.000 only got 1 purchase, so it would have to show 1 time and show +6 times...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;Do I explain well? Let me know if you have any doubts about the result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 09:06:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2102535#M61982</guid>
      <dc:creator>modwonka</dc:creator>
      <dc:date>2021-09-28T09:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2102623#M61985</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="322392" data-lia-user-login="modwonka" class="lia-mention lia-mention-user"&gt;modwonka&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Using 9/15-9/16 as a date range, the result should be like this?&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;If so, change the column formula:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;No. of Purchases = 
VAR BuyID =
    CALCULATE (
        COUNT ( 'Table'[ID] ),
        FILTER (
            'Table',
            'Table'[Tyoe of order] = "Buy"
                &amp;amp;&amp;amp; 'Table'[ID] = EARLIER ( 'Table'[ID] )
                &amp;amp;&amp;amp; 'Table'[Date].[Date] = EARLIER('Table'[Date].[Date])
        )
    )
VAR NPurchase =
    SWITCH (
        TRUE (),
        BuyID = 1, "1 times",
        BuyID = 2, "2 times",
        BuyID = 3, "3 times",
        BuyID = 4, "4 times",
        BuyID = 5, "5 times",
        BuyID &amp;gt;= 6, "6+ times"
    )
RETURN
    NPurchase&lt;/LI-CODE&gt;
&lt;P&gt;Count formula:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count = COUNTX ( SUMMARIZE ( 'Table', 'Table'[ID], 'Table'[No. of Purchases],'Table'[Date].[Date] ), [ID] )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Yingjie Li&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 09:30:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2102623#M61985</guid>
      <dc:creator>v-yingjl</dc:creator>
      <dc:date>2021-09-28T09:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2103093#M61996</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="199176" data-lia-user-login="v-yingjl" class="lia-mention lia-mention-user"&gt;v-yingjl&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You almost get the solution except by one thing. You can see the ID 5000 appears double.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;5000 - 1 time&lt;/LI&gt;&lt;LI&gt;5000 - 6+ times&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;You would have only one 5000 with 6+ times. This customer has done 6+ purchases in the period you have choosen.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that possible?&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 13:38:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2103093#M61996</guid>
      <dc:creator>modwonka</dc:creator>
      <dc:date>2021-09-28T13:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2104249#M62022</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="322392" data-lia-user-login="modwonka" class="lia-mention lia-mention-user"&gt;modwonka&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;All right, the table total count should be the same as the left table if I understand it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count = CALCULATE(COUNT('Table'[ID]),'Table'[Tyoe of order] = "Buy")&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;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Yingjie Li&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 01:46:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2104249#M62022</guid>
      <dc:creator>v-yingjl</dc:creator>
      <dc:date>2021-09-29T01:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2105011#M62036</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="199176" data-lia-user-login="v-yingjl" class="lia-mention lia-mention-user"&gt;v-yingjl&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No, the result would be this.&amp;nbsp;&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;Cheers!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 08:23:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2105011#M62036</guid>
      <dc:creator>modwonka</dc:creator>
      <dc:date>2021-09-29T08:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2105124#M62039</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="322392" data-lia-user-login="modwonka" class="lia-mention lia-mention-user"&gt;modwonka&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Re-create two measures because the No. Of Purchases should be dynamic not static and need to use ID column as context becasue only put two measures in the visual would only show the aggreated value.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;No. of Purchases = 
VAR mindate =
    CALCULATE ( MIN ( 'Table'[Date].[Date] ), ALLSELECTED ( 'Table' ) )
VAR maxdate =
    CALCULATE ( MAX ( 'Table'[Date].[Date] ), ALLSELECTED ( 'Table' ) )
VAR BuyID =
    CALCULATE (
        COUNT ( 'Table'[ID] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Tyoe of order] = "Buy"
                &amp;amp;&amp;amp; 'Table'[ID]
                    IN DISTINCT ( 'Table'[ID] )
                        &amp;amp;&amp;amp; 'Table'[Date].[Date] &amp;gt;= mindate
                        &amp;amp;&amp;amp; 'Table'[Date].[Date] &amp;lt;= maxdate
        )
    )
VAR NPurchase =
    SWITCH (
        TRUE (),
        BuyID = 1, "1 times",
        BuyID = 2, "2 times",
        BuyID = 3, "3 times",
        BuyID = 4, "4 times",
        BuyID = 5, "5 times",
        BuyID &amp;gt;= 6, "6+ times"
    )
RETURN
    NPurchase&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Count = 
COUNTX ( SUMMARIZE ( 'Table', 'Table'[ID], "A", [No. of Purchases] ), [A] )&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;Community Support Team _ Yingjie Li&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 08:59:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2105124#M62039</guid>
      <dc:creator>v-yingjl</dc:creator>
      <dc:date>2021-09-29T08:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2106296#M62074</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="199176" data-lia-user-login="v-yingjl" class="lia-mention lia-mention-user"&gt;v-yingjl&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks again! that solution is ok but it's not the perfect one. Why? To have the correct result, i would have always to add ID column to the table. I don't want to do that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanna have one table with only this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Group by nº of purchases and count the nº of IDs do the action. If there are two customers that buy two times in the period i choose, i wanna see in table 2 count in 2 times row, for example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you do that?&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 17:09:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2106296#M62074</guid>
      <dc:creator>modwonka</dc:creator>
      <dc:date>2021-09-29T17:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2106845#M62101</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="322392" data-lia-user-login="modwonka" class="lia-mention lia-mention-user"&gt;modwonka&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I'm afraid not. As my previous posted, you need a dynamic No. of Purchases with a date slicer so it must be a measure not a calculated column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this situation, it must need a column as context, if only put measures in the visual, you can only see '6+ times' because there is no context in the visual for the measure to calculate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Yingjie Li&lt;BR /&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 01:27:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2106845#M62101</guid>
      <dc:creator>v-yingjl</dc:creator>
      <dc:date>2021-09-30T01:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rows by Group with Filter</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2107943#M62127</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="199176" data-lia-user-login="v-yingjl" class="lia-mention lia-mention-user"&gt;v-yingjl&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ok! Bad luck...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, i think to avoid that, we can create a table with different columns with a fixed period.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the first code, you developed a calculated column. That calculated column can be all the period with data. And then, could we created fixed column with a certain time?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, that would be the final result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;One column to all the period we have in column "Date".&lt;/LI&gt;&lt;LI&gt;One column to last day of "Date"&lt;/LI&gt;&lt;LI&gt;One column to last week of "Date".&lt;/LI&gt;&lt;LI&gt;One column to last month of "Date".&lt;/LI&gt;&lt;LI&gt;One column to last 6 months of "Date".&lt;/LI&gt;&lt;LI&gt;One column to last 1 year of "Date".&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;With these columns, we can choose the date, but at least we can have the frequency of that period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do you see?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!!&lt;/P&gt;&lt;P&gt;cheers!&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 10:25:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Count-Rows-by-Group-with-Filter/m-p/2107943#M62127</guid>
      <dc:creator>modwonka</dc:creator>
      <dc:date>2021-09-30T10:25:52Z</dc:date>
    </item>
  </channel>
</rss>

