<?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: Calculate Average Price  by row for aggregated Qty and Sales for various products. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2882138#M93323</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="299232" data-lia-user-login="BudMan512" class="lia-mention lia-mention-user"&gt;BudMan512&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here I suggest you to try to create a measure instead of a calculated column.&lt;/P&gt;
&lt;P&gt;[Total &lt;SPAN&gt;gallons&lt;/SPAN&gt;] and [Total Sales] should both be measure as well. Then you can show your result in a table visual.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Avg Sell Price = DIVIDE(History[Total Sales],History[total Gallons],0)
&lt;/LI-CODE&gt;
&lt;P&gt;Result is as below.&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;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Nov 2022 07:44:18 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-11-03T07:44:18Z</dc:date>
    <item>
      <title>Calculate Average Price  by row for aggregated Qty and Sales for various products.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2881370#M93281</link>
      <description>&lt;P&gt;I have a list of customer purchaces of various fuels for which I have summed the Qty and Sales by Category and Branch. I would like to find the average price of each product.&amp;nbsp; &amp;nbsp;I have attached a spreadsheet with Test Data and also including my desired output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the DAX I used to sum the QTY. The Inv_Multiplier is a conversion factor for various fuels and can be ignored:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Total gallons = CALCULATE(SUMX(History, History[QTY] * History[INV_MULTIPLIER]))&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Here is the DAX for Total Sales:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Total Sales = CALCULATE(SUMX(History, History[Sales]))&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;And here is the DAX for Avg Sell Price, which is driving me crazy.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Avg Sell Price = DIVIDE(History[Total Sales],History[total Gallons],0)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is when I set my Avg Sell Price 'Summerization' to 'Sum', it sums up all the individual transaction's average prices, not good.&lt;/P&gt;&lt;P&gt;If I set the Avg Sell Price 'Summerization' to 'Don't summarize', it gives me the Average Sell Price for each individual transaction, that's worse.&lt;/P&gt;&lt;P&gt;What I hope to find is DAX that will allow me to calculate the the Avg Sell Price for each row.&amp;nbsp; Desired output is below .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my Input History table:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&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;Here is a link to the spreadsheet.&amp;nbsp; Let me know if this doesn't work as I have not tried this before.&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.google.com/spreadsheets/d/1F3dCbXLF1X2eu96kKRVmVtHDjKAwRDNZ/edit?usp=share_link&amp;amp;ouid=108795197017177326252&amp;amp;rtpof=true&amp;amp;sd=true" target="_blank" rel="noopener"&gt;https://docs.google.com/spreadsheets/d/1F3dCbXLF1X2eu96kKRVmVtHDjKAwRDNZ/edit?usp=share_link&amp;amp;ouid=108795197017177326252&amp;amp;rtpof=true&amp;amp;sd=true&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Bud&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 22:10:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2881370#M93281</guid>
      <dc:creator>BudMan512</dc:creator>
      <dc:date>2022-11-02T22:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Price  by row for aggregated Qty and Sales for various products.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2881722#M93299</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="299232" data-lia-user-login="BudMan512" class="lia-mention lia-mention-user"&gt;BudMan512&lt;/a&gt; , for that you need a column &lt;/P&gt;
&lt;P&gt;Price column =&lt;/P&gt;
&lt;P&gt;divide(History[QTY] * History[INV_MULTIPLIER] ,History[Sales])&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 02:57:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2881722#M93299</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-11-03T02:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Price  by row for aggregated Qty and Sales for various products.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2882138#M93323</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="299232" data-lia-user-login="BudMan512" class="lia-mention lia-mention-user"&gt;BudMan512&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here I suggest you to try to create a measure instead of a calculated column.&lt;/P&gt;
&lt;P&gt;[Total &lt;SPAN&gt;gallons&lt;/SPAN&gt;] and [Total Sales] should both be measure as well. Then you can show your result in a table visual.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Avg Sell Price = DIVIDE(History[Total Sales],History[total Gallons],0)
&lt;/LI-CODE&gt;
&lt;P&gt;Result is as below.&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;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 07:44:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2882138#M93323</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-03T07:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Price  by row for aggregated Qty and Sales for various products.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2882918#M93369</link>
      <description>&lt;P&gt;Hi Rico, thanks for the reply.&lt;/P&gt;&lt;P&gt;What you have prescribed is what I have,&amp;nbsp; all DAX is in measures, here they are:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Total gallons = CALCULATE(SUMX(History, History[QTY] * History[INV_MULTIPLIER])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Total Sales = CALCULATE(SUMX(History, History[Sales]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Avg Sell Price = DIVIDE(History[Total Sales],History[total Gallons],0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Yet my result is different.&amp;nbsp; When I Sum the Avg Sell Price measure, the table appears the way I want, but it appears to be summing the Avg of individual transactions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When I choose not to sum. it then displays every individual transaction, rather than an aggregated table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there something different causing my problem?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I appreciatae the help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Bud&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 13:02:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2882918#M93369</guid>
      <dc:creator>BudMan512</dc:creator>
      <dc:date>2022-11-03T13:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Price  by row for aggregated Qty and Sales for various products.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2882960#M93375</link>
      <description>&lt;P&gt;Thanks for the reply amitchanda.&amp;nbsp; I tried to create a Price column but it produced the same problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are all measures.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Total gallons = CALCULATE(SUMX(History, History[QTY] * History[INV_MULTIPLIER])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Total Sales = CALCULATE(SUMX(History, History[Sales]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Avg Sell Price = DIVIDE(History[Total Sales],History[total Gallons],0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is the calculated column I tried.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Price = &lt;/SPAN&gt;&lt;SPAN&gt;DIVIDE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;History[QTY]&lt;/SPAN&gt;&lt;SPAN&gt; * &lt;/SPAN&gt;&lt;SPAN&gt;History[INV_MULTIPLIER]&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;History[TOTAL_PRICE]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;This is what I am getting for results, with my measure and your Price column.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;Thanks for your time.&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 03 Nov 2022 13:15:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2882960#M93375</guid>
      <dc:creator>BudMan512</dc:creator>
      <dc:date>2022-11-03T13:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Price  by row for aggregated Qty and Sales for various products.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2883762#M93426</link>
      <description>&lt;P&gt;Hi Rico, my apologies, my Avg Sell Price was not a measure but a calculated column.&amp;nbsp; I couldn't get an acurate value thou until I used this DAX:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Avg Sell Price = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DIVIDE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;History&lt;/SPAN&gt;&lt;SPAN&gt;[Total Sales]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;History&lt;/SPAN&gt;&lt;SPAN&gt;[total Gallons]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks for helping,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Bud&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 03 Nov 2022 19:30:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2883762#M93426</guid>
      <dc:creator>BudMan512</dc:creator>
      <dc:date>2022-11-03T19:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Average Price  by row for aggregated Qty and Sales for various products.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2883768#M93427</link>
      <description>&lt;P&gt;Hi amitchandak,&amp;nbsp; Here is the measure that ended up working for me:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Avg Sell Price = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DIVIDE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;History&lt;/SPAN&gt;&lt;SPAN&gt;[Total Sales]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;History&lt;/SPAN&gt;&lt;SPAN&gt;[total Gallons]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I tried everything else under the sun but this works.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks for answering by question.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Bud&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 03 Nov 2022 19:34:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Average-Price-by-row-for-aggregated-Qty-and-Sales-for/m-p/2883768#M93427</guid>
      <dc:creator>BudMan512</dc:creator>
      <dc:date>2022-11-03T19:34:33Z</dc:date>
    </item>
  </channel>
</rss>

