<?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 Average - Distinct in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Distinct/m-p/3860438#M150803</link>
    <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Spool =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;AVERAGE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'AllInvoiceDetails'&lt;/SPAN&gt;&lt;SPAN&gt;[Quantity]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;'Product'&lt;/SPAN&gt;&lt;SPAN&gt;[ProductGroup]&lt;/SPAN&gt;&lt;SPAN&gt; = { &lt;/SPAN&gt;&lt;SPAN&gt;"Spool"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I have the above formula but it is not working.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;In the Product Group there may be 2 values with "Spool"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I think I just need to add a Distinct but I keep getting errors.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Where there is 2, I am getting double the number.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Can someone tell me how to add a Distinct.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 22 Apr 2024 21:59:08 GMT</pubDate>
    <dc:creator>Damian911</dc:creator>
    <dc:date>2024-04-22T21:59:08Z</dc:date>
    <item>
      <title>Average - Distinct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Distinct/m-p/3860438#M150803</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Spool =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;AVERAGE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'AllInvoiceDetails'&lt;/SPAN&gt;&lt;SPAN&gt;[Quantity]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;'Product'&lt;/SPAN&gt;&lt;SPAN&gt;[ProductGroup]&lt;/SPAN&gt;&lt;SPAN&gt; = { &lt;/SPAN&gt;&lt;SPAN&gt;"Spool"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I have the above formula but it is not working.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;In the Product Group there may be 2 values with "Spool"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I think I just need to add a Distinct but I keep getting errors.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Where there is 2, I am getting double the number.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Can someone tell me how to add a Distinct.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 22 Apr 2024 21:59:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Distinct/m-p/3860438#M150803</guid>
      <dc:creator>Damian911</dc:creator>
      <dc:date>2024-04-22T21:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Average - Distinct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Distinct/m-p/3860951#M150829</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please share your sample pbix file's link.&lt;/P&gt;
&lt;P&gt;Or, please try something like below whether it suits your requirement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Spool =
CALCULATE (
    AVERAGE ( 'AllInvoiceDetails'[Quantity] ),
    'Product'[ProductGroup] IN { "Spool" }
)
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 23 Apr 2024 03:19:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Distinct/m-p/3860951#M150829</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-04-23T03:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: Average - Distinct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Distinct/m-p/3861364#M150843</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="419528" data-lia-user-login="Damian911" class="lia-mention lia-mention-user"&gt;Damian911&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I am glad to help you.&lt;BR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt;&amp;nbsp;，Thank you very much for your help with this case!&lt;BR /&gt;I've come up with another solution that I'd like to share.&lt;/P&gt;&lt;P&gt;Based on your description, I think you can try to change the DAX code to this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Spool = 
CALCULATE(
    AVERAGE('AllInvoiceDetails'[Quantity]),
    FILTER(
        'Product',
        'Product'[ProductGroup] = "Spool"
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created the following test data as you described it.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;It is recommended to use the filter function in the calculate function to filter out a separate range for calculation (from the Product table to filter out ProductGroup = "Spool" rows of data), then only ProductGroup for the "Spool" rows will be used in the previous average method. (Requires a relationship between the tables.)&lt;/P&gt;&lt;P&gt;Using the filter function, it is possible to individually restrict a calculation range (creating a new table), which does not affect the other dax expressions of the model.&lt;BR /&gt;&lt;BR /&gt;Here's what happens when no relationship is created between tables:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The results for both are incorrect.&lt;BR /&gt;When a relationship is established between two tables:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above code not only calculates the average value in the "spool" according to the filter range, but also calculates the duplicate ID (value 2) records only once.&lt;BR /&gt;The above measure using the filter function is correct, and correspondingly, the following expression does not change the filter range before and after the relationship is created.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Carson Jian,&lt;BR /&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 07:11:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Distinct/m-p/3861364#M150843</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-23T07:11:39Z</dc:date>
    </item>
  </channel>
</rss>

