<?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 Finding count of rows in subgroup and flagging when there is only one row in the group in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-count-of-rows-in-subgroup-and-flagging-when-there-is/m-p/4284627#M170053</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am looking for a measure that gives me the count when there is only one row with Rating = "Good" for every ID.&lt;/P&gt;&lt;P&gt;Every ID can have multiple Sub_ID. Sub_ID are shared among IDs. Rating is for the ID column.&lt;/P&gt;&lt;P&gt;From the below example for 11/1/2024, only 567 is counted, for 11/8/2024, 234 is counted&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;ID_Column&lt;/TD&gt;&lt;TD&gt;SubID_Column&lt;/TD&gt;&lt;TD&gt;Rating&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/1/2024&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;456&lt;/TD&gt;&lt;TD&gt;Good&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/1/2024&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;678&lt;/TD&gt;&lt;TD&gt;Avg&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/1/2024&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;666&lt;/TD&gt;&lt;TD&gt;Bad&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/8/2024&lt;/TD&gt;&lt;TD&gt;234&lt;/TD&gt;&lt;TD&gt;455&lt;/TD&gt;&lt;TD&gt;Good&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/1/2024&lt;/TD&gt;&lt;TD&gt;345&lt;/TD&gt;&lt;TD&gt;455&lt;/TD&gt;&lt;TD&gt;Good&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/1/2024&lt;/TD&gt;&lt;TD&gt;345&lt;/TD&gt;&lt;TD&gt;890&lt;/TD&gt;&lt;TD&gt;Good&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/8/2024&lt;/TD&gt;&lt;TD&gt;567&lt;/TD&gt;&lt;TD&gt;900&lt;/TD&gt;&lt;TD&gt;Avg&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/1/2024&lt;/TD&gt;&lt;TD&gt;567&lt;/TD&gt;&lt;TD&gt;900&lt;/TD&gt;&lt;TD&gt;Good&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Thanks in advance for your time.&lt;/P&gt;</description>
    <pubDate>Thu, 14 Nov 2024 20:19:52 GMT</pubDate>
    <dc:creator>Msri</dc:creator>
    <dc:date>2024-11-14T20:19:52Z</dc:date>
    <item>
      <title>Finding count of rows in subgroup and flagging when there is only one row in the group</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-count-of-rows-in-subgroup-and-flagging-when-there-is/m-p/4284627#M170053</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am looking for a measure that gives me the count when there is only one row with Rating = "Good" for every ID.&lt;/P&gt;&lt;P&gt;Every ID can have multiple Sub_ID. Sub_ID are shared among IDs. Rating is for the ID column.&lt;/P&gt;&lt;P&gt;From the below example for 11/1/2024, only 567 is counted, for 11/8/2024, 234 is counted&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD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&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Thanks in advance for your time.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2024 20:19:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-count-of-rows-in-subgroup-and-flagging-when-there-is/m-p/4284627#M170053</guid>
      <dc:creator>Msri</dc:creator>
      <dc:date>2024-11-14T20:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Finding count of rows in subgroup and flagging when there is only one row in the group</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-count-of-rows-in-subgroup-and-flagging-when-there-is/m-p/4284996#M170076</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="825090" data-lia-user-login="Msri" class="lia-mention lia-mention-user"&gt;Msri&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you need to group the data based on 'Date' and 'ID_Column' and then calculate the number of groups that contain only one 'Good' item? This would provide a table showing the date and count. If that’s the case, could you clarify why the entry for '123' on November 1st is not included? It has only one 'Good' on that day. Additionally, could you provide a sample of the result you’re aiming for?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Bof&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 02:29:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-count-of-rows-in-subgroup-and-flagging-when-there-is/m-p/4284996#M170076</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-15T02:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: Finding count of rows in subgroup and flagging when there is only one row in the group</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-count-of-rows-in-subgroup-and-flagging-when-there-is/m-p/4285140#M170082</link>
      <description>&lt;P&gt;Hi Bof,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for replying, Date is in the filters so i dont essentially need to group by date in the DAX. I need&amp;nbsp;a count of ID_Column when the count(SubID_Column) = 1 and its Rating = Good. 123 was not counted as it had Sub_ID count = 3. The measure should return the distinct ID_Column count. This count is then used in the table that is split by Zones. (SQL has zones aligned for every ID_column)&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 04:22:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-count-of-rows-in-subgroup-and-flagging-when-there-is/m-p/4285140#M170082</guid>
      <dc:creator>Msri</dc:creator>
      <dc:date>2024-11-15T04:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Finding count of rows in subgroup and flagging when there is only one row in the group</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-count-of-rows-in-subgroup-and-flagging-when-there-is/m-p/4285323#M170094</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="825090" data-lia-user-login="Msri" class="lia-mention lia-mention-user"&gt;Msri&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because your request involves complex grouping operations, I have used Power Query to implement this.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRecords({
        [Date="11/1/2024", ID_Column=123, SubID_Column=456, Rating="Good"],
        [Date="11/1/2024", ID_Column=123, SubID_Column=678, Rating="Avg"],
        [Date="11/1/2024", ID_Column=123, SubID_Column=666, Rating="Bad"],
        [Date="11/8/2024", ID_Column=234, SubID_Column=455, Rating="Good"],
        [Date="11/1/2024", ID_Column=345, SubID_Column=455, Rating="Good"],
        [Date="11/1/2024", ID_Column=345, SubID_Column=890, Rating="Good"],
        [Date="11/8/2024", ID_Column=567, SubID_Column=900, Rating="Avg"],
        [Date="11/1/2024", ID_Column=567, SubID_Column=900, Rating="Good"]
    }),
    
    GroupedRows = Table.Group(Source, {"ID_Column"}, {
        {"GroupedData", each _, type table [Date=nullable date, ID_Column=number, SubID_Column=number, Rating=text]}
    }),

    AddGoodAndCount = Table.AddColumn(GroupedRows, "FilteredData", each 
        let
            GroupData = [GroupedData],
            DistinctSubID = Table.Distinct(GroupData, {"SubID_Column"}),
            FilterGood=Table.SelectRows(GroupData,each [Rating]="Good"),
            CountGood=Table.RowCount(FilterGood),
            CountSubID = Table.RowCount(DistinctSubID)
        in
            if CountGood = 1 and CountSubID=1 then Table.Distinct(FilterGood, {"SubID_Column"}) else null
    ),
    #"Expanded FilteredData" = Table.ExpandTableColumn(AddGoodAndCount, "FilteredData", {"Date", "ID_Column", "SubID_Column", "Rating"}, {"Date", "WaitForRemove", "SubID_Column", "Rating"}),
    FilterNull=Table.SelectRows(#"Expanded FilteredData",each [Rating] &amp;lt;&amp;gt; null),
    RemovColumns=Table.RemoveColumns(FilterNull,{"GroupedData","WaitForRemove"})
in
    RemovColumns&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;Before&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;After&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;/P&gt;
&lt;P&gt;Bof&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 06:01:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-count-of-rows-in-subgroup-and-flagging-when-there-is/m-p/4285323#M170094</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-15T06:01:13Z</dc:date>
    </item>
  </channel>
</rss>

