<?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: wrong result when applying divide with blank value in details in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/wrong-result-when-applying-divide-with-blank-value-in-details/m-p/3167584#M114032</link>
    <description>&lt;P&gt;Thank you &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="460868" data-lia-user-login="FreemanZ" class="lia-mention lia-mention-user"&gt;FreemanZ&lt;/a&gt;&amp;nbsp; , it works&lt;/P&gt;</description>
    <pubDate>Sun, 02 Apr 2023 06:16:28 GMT</pubDate>
    <dc:creator>GiladO</dc:creator>
    <dc:date>2023-04-02T06:16:28Z</dc:date>
    <item>
      <title>wrong result when applying divide with blank value in details</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/wrong-result-when-applying-divide-with-blank-value-in-details/m-p/3164039#M113717</link>
      <description>&lt;P&gt;Hello Community ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create an average price by dividing sales amount by quantity.&lt;/P&gt;&lt;P&gt;I have filter records in the amount variable so calculation will apply only on records that the amount is greater than 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;The same calculation is apply on qty that should be greater than 0&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems that aggregate divide result is incorrect as some of calculation result in detail are equal to blank.&lt;/P&gt;&lt;P&gt;I know I need to filter out blank but I did not succeed to get correct result.&lt;/P&gt;&lt;P&gt;please advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;avg_price =&lt;BR /&gt;var vprice = CALCULATE(&lt;BR /&gt;SUM(INVOICES[Amount]),&lt;BR /&gt;CALCULATETABLE(&lt;BR /&gt;VALUES('INVOICES'),&lt;BR /&gt;'INVOICES'[Amount] &amp;gt; 1&lt;BR /&gt;))&lt;BR /&gt;var vqty = CALCULATE(&lt;BR /&gt;SUM(INVOICES[qty]),&lt;BR /&gt;CALCULATETABLE(&lt;BR /&gt;VALUES('INVOICES'),&lt;BR /&gt;'INVOICES'[qty] &amp;gt; 0&lt;BR /&gt;))&lt;BR /&gt;return DIVIDE(vprice , vqty, 0)&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 17:29:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/wrong-result-when-applying-divide-with-blank-value-in-details/m-p/3164039#M113717</guid>
      <dc:creator>Gilad</dc:creator>
      <dc:date>2023-03-30T17:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: wrong result when applying divide with blank value in details</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/wrong-result-when-applying-divide-with-blank-value-in-details/m-p/3164626#M113762</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="539205" data-lia-user-login="Gilad" class="lia-mention lia-mention-user"&gt;Gilad&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the filters need to be applied for each row of your table &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;simultaneously&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Supposing your data is like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Amt&lt;/TD&gt;&lt;TD&gt;Qty&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;-1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;try to plot a measure like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Avg Price = 
VAR _table = 
FILTER(
    TableName, 
    TableName[Amt]&amp;gt;1&amp;amp;&amp;amp;TableName[Qty]&amp;gt;0
)
VAR _amt = SUMX(_table, TableName[Amt])
VAR _qty = SUMX(_table, TableName[Qty])
RETURN 
DIVIDE(_amt, _qty)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it worked like:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 02:00:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/wrong-result-when-applying-divide-with-blank-value-in-details/m-p/3164626#M113762</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-03-31T02:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: wrong result when applying divide with blank value in details</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/wrong-result-when-applying-divide-with-blank-value-in-details/m-p/3167584#M114032</link>
      <description>&lt;P&gt;Thank you &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="460868" data-lia-user-login="FreemanZ" class="lia-mention lia-mention-user"&gt;FreemanZ&lt;/a&gt;&amp;nbsp; , it works&lt;/P&gt;</description>
      <pubDate>Sun, 02 Apr 2023 06:16:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/wrong-result-when-applying-divide-with-blank-value-in-details/m-p/3167584#M114032</guid>
      <dc:creator>GiladO</dc:creator>
      <dc:date>2023-04-02T06:16:28Z</dc:date>
    </item>
  </channel>
</rss>

