<?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: Exclude items from distinct count on higher level of aggregation in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373477#M173629</link>
    <description>&lt;P&gt;I think you can use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Num Lost =
SUMX (
    DISTINCT ( F_OrderItem[order_key] ),
    VAR Flags =
        VALUES ( F_OrderItem[lost_flag] )
    VAR Result =
        IF (
            COUNTROWS ( Flags ) = 1
                &amp;amp;&amp;amp; SELECTEDVALUE ( F_OrderItem[lost_flag] ) = 1,
            1,
            0
        )
    RETURN
        Result
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jan 2025 11:00:23 GMT</pubDate>
    <dc:creator>johnt75</dc:creator>
    <dc:date>2025-01-21T11:00:23Z</dc:date>
    <item>
      <title>Exclude items from distinct count on higher level of aggregation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373377#M173623</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a measure&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;CALCULATE( DISTINCTCOUNT(F_OrderItem[order_key]), F_OrderItem[lost_flag] = 1 )&lt;/LI-CODE&gt;&lt;P&gt;to calculate orders that are lost - not part of the sale. But it can be lost one day but successfully sold next day. On a daily level it works fine but on a monthly / city / ... level I would need to count only those that still have lost flag = 1 on all occurrences for that aggregation level. With other words, if the order has a lost flag = 1 in one day but = 0 the next day it should be counted as lost for 1st day but for the whole month not anymore.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you help me modify the measure?&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 10:00:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373377#M173623</guid>
      <dc:creator>soldous</dc:creator>
      <dc:date>2025-01-21T10:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude items from distinct count on higher level of aggregation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373397#M173624</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="64216" data-lia-user-login="soldous" class="lia-mention lia-mention-user"&gt;soldous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;H6&gt;Lost Orders = &lt;BR /&gt;CALCULATE(&lt;BR /&gt;DISTINCTCOUNT(F_OrderItem[order_key]),&lt;BR /&gt;FILTER(&lt;BR /&gt;SUMMARIZE(&lt;BR /&gt;F_OrderItem,&lt;BR /&gt;F_OrderItem[order_key],&lt;BR /&gt;"AllLost", MAX(F_OrderItem[lost_flag])&lt;BR /&gt;),&lt;BR /&gt;[AllLost] = 1&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/H6&gt;
&lt;DIV&gt;&lt;span class="lia-unicode-emoji" title=":light_bulb:"&gt;💡&lt;/span&gt; &lt;STRONG&gt;If this helped, please give Kudos &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; or mark it as a Solution &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt;.&lt;/STRONG&gt;&lt;BR /&gt;&lt;EM&gt;Best regards,&lt;BR /&gt;&lt;STRONG&gt;Kedar&lt;/STRONG&gt;&lt;EM&gt;&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/kedar-pande" target="_blank"&gt;&lt;span class="lia-unicode-emoji" title=":globe_with_meridians:"&gt;🌐&lt;/span&gt; Connect on LinkedIn&lt;/A&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 21 Jan 2025 10:06:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373397#M173624</guid>
      <dc:creator>Kedar_Pande</dc:creator>
      <dc:date>2025-01-21T10:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude items from distinct count on higher level of aggregation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373432#M173626</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="568855" data-lia-user-login="Kedar_Pande" class="lia-mention lia-mention-user"&gt;Kedar_Pande&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;still the same:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I have selected just one item. "Lost" is original measure, "measure" is the new one. In month total it should return 0 because for 15.1. the order is not lost anymore.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 10:28:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373432#M173626</guid>
      <dc:creator>soldous</dc:creator>
      <dc:date>2025-01-21T10:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude items from distinct count on higher level of aggregation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373477#M173629</link>
      <description>&lt;P&gt;I think you can use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Num Lost =
SUMX (
    DISTINCT ( F_OrderItem[order_key] ),
    VAR Flags =
        VALUES ( F_OrderItem[lost_flag] )
    VAR Result =
        IF (
            COUNTROWS ( Flags ) = 1
                &amp;amp;&amp;amp; SELECTEDVALUE ( F_OrderItem[lost_flag] ) = 1,
            1,
            0
        )
    RETURN
        Result
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 11:00:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373477#M173629</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2025-01-21T11:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude items from distinct count on higher level of aggregation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373485#M173631</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; &amp;amp;&amp;amp; SELECTEDVALUE ( F_OrderItem[order_key] ) = 1&lt;/LI-CODE&gt;&lt;P&gt;should mean please? Order key is string data type so your measure returns error&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 10:58:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373485#M173631</guid>
      <dc:creator>soldous</dc:creator>
      <dc:date>2025-01-21T10:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude items from distinct count on higher level of aggregation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373490#M173632</link>
      <description>&lt;P&gt;My mistake, that should have been lost_flag, not order_key. I have edited my original post to reflect that.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 11:01:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373490#M173632</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2025-01-21T11:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude items from distinct count on higher level of aggregation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373511#M173636</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;still doesnt work &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I select just one order it works as expected:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;but with all selected you can see that for 3.1. it still returns 1 correctly but that 1 is not propagated to the higher level but should be:&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;</description>
      <pubDate>Tue, 21 Jan 2025 11:16:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373511#M173636</guid>
      <dc:creator>soldous</dc:creator>
      <dc:date>2025-01-21T11:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude items from distinct count on higher level of aggregation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373515#M173637</link>
      <description>&lt;P&gt;A couple of things here. The values of 0 on 15th and 16th should be propagated to the month level, no ?&lt;/P&gt;
&lt;P&gt;Also, I had expected that the only values for lost_flag would be 0 or 1. What values could that column contain ?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 11:21:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373515#M173637</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2025-01-21T11:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude items from distinct count on higher level of aggregation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373536#M173639</link>
      <description>&lt;P&gt;lost_flag has only two values 0 or 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;the expected result should be:&lt;/P&gt;&lt;P&gt;3.1. - 1&lt;/P&gt;&lt;P&gt;11.1. - 1&lt;/P&gt;&lt;P&gt;13.1. - 1&lt;/P&gt;&lt;P&gt;14.1. - 2 but here the order 16031 is not lost anymore for 15th - should not be counted on monthly level&lt;/P&gt;&lt;P&gt;15.1. - 1&lt;/P&gt;&lt;P&gt;16.1. - 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and on 202501 monthly level it should return &lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 11:32:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373536#M173639</guid>
      <dc:creator>soldous</dc:creator>
      <dc:date>2025-01-21T11:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude items from distinct count on higher level of aggregation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373759#M173656</link>
      <description>&lt;P&gt;OK, I think this works&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Num Lost = 
SUMX (
    DISTINCT ( F_OrderItem[order_key] ),
    VAR Flags =
        CALCULATETABLE( VALUES ( F_OrderItem[lost_flag] ) )
    VAR Result =
        IF (
            COUNTROWS ( Flags ) = 1
                &amp;amp;&amp;amp; CALCULATE( SELECTEDVALUE ( F_OrderItem[lost_flag] ) ) = 1,
            1,
            0
        )
    RETURN
        Result
)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 21 Jan 2025 13:50:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373759#M173656</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2025-01-21T13:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude items from distinct count on higher level of aggregation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373791#M173660</link>
      <description>&lt;P&gt;It works it seems. Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 14:11:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Exclude-items-from-distinct-count-on-higher-level-of-aggregation/m-p/4373791#M173660</guid>
      <dc:creator>soldous</dc:creator>
      <dc:date>2025-01-21T14:11:16Z</dc:date>
    </item>
  </channel>
</rss>

