<?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: Calculating weighted avg on rows with shared descriptions in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078485#M107136</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="514180" data-lia-user-login="Nick-LWI" class="lia-mention lia-mention-user"&gt;Nick-LWI&lt;/a&gt;&amp;nbsp; sure&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
DIVIDE (
    SUMX (
        FILTER ( ALL ( 'Table 1' ), 'Table 1'[Desc] = MAX ( 'Table 1'[Desc] ) ),
        'Table 1'[Price] * 'Table 1'[Qty]
    ),
    CALCULATE ( SUM ( 'Table 1'[Qty] ), ALLEXCEPT ( 'Table 1', 'Table 1'[Desc] ) )
)&lt;/LI-CODE&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;</description>
    <pubDate>Mon, 13 Feb 2023 22:44:13 GMT</pubDate>
    <dc:creator>smpa01</dc:creator>
    <dc:date>2023-02-13T22:44:13Z</dc:date>
    <item>
      <title>Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078289#M107125</link>
      <description>&lt;P&gt;Hi, I'm fairly new to PowerBI so I'm sure there's an obvious solution that I'm unable to stumble into but here's what I'm trying to do: I need a formula that looks at the "Desc" field and calculates the weighted average of items that share a description.&amp;nbsp; There's a dummy table below.&amp;nbsp; The weighted average part is easy enough, but I don't know how to have it evaluate like items.&amp;nbsp; Also there's like 100 different item descriptions in my real data so I can't use a FILTER expression since it requires a hard reference and not a variable one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Desc&lt;/TD&gt;&lt;TD&gt;Price&lt;/TD&gt;&lt;TD&gt;Qty&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABCD&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABCD&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;EFG&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;EFG&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABCD&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;EFG&lt;/TD&gt;&lt;TD&gt;18&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;YZ&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;YZ&lt;/TD&gt;&lt;TD&gt;110&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;EFG&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABCD&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;YZ&lt;/TD&gt;&lt;TD&gt;120&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I need a measure that says the weighted average price on ABCD is 10, EFG is 17.14, YZ is 104.28, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 19:02:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078289#M107125</guid>
      <dc:creator>Nick-LWI</dc:creator>
      <dc:date>2023-02-13T19:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078308#M107126</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="514180" data-lia-user-login="Nick-LWI" class="lia-mention lia-mention-user"&gt;Nick-LWI&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;weighted average =&lt;BR /&gt;AVERAGEX (&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;'Table',&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;'Table'[Price] *&amp;nbsp;'Table'[Qty]&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 19:23:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078308#M107126</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-02-13T19:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078317#M107128</link>
      <description>&lt;P&gt;tamerj1, thank you for the reponse however I need a weighted average that varies based on the "Desc" field.&amp;nbsp; That variable weighted average is then used for profit calculations on individual orders.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally your formula doesn't appear to work correctly with the data, for example on item "ABCD" it would yield 20 when the true weighted average is 10.&amp;nbsp; I believe that for a straight weighted average one would use DIVIDE(SUMX(table, table[Price]*table[Qty]),SUMX(table,table[Qty]) however this doesn't account for the differences in description.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 19:40:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078317#M107128</guid>
      <dc:creator>Nick-LWI</dc:creator>
      <dc:date>2023-02-13T19:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078376#M107132</link>
      <description>&lt;P&gt;Two ways you can write them....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Avg Total 2 = AVERAGEX(FILTER(ALLSELECTED('DataTable'),'DataTable'[Desc]=MAX('DataTable'[Desc])),'DataTable'[Price])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Avg Total = CALCULATE(AVERAGE('DataTable'[Price]),FILTER(ALLSELECTED('DataTable'),'DataTable'[Desc]=MAX('DataTable'[Desc])))&lt;/LI-CODE&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>Mon, 13 Feb 2023 20:56:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078376#M107132</guid>
      <dc:creator>BrianConnelly</dc:creator>
      <dc:date>2023-02-13T20:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078430#M107134</link>
      <description>&lt;P&gt;Thank you Brian, it looks like this is calculating correctly when the measure is brought into a table, but do you know how to incorporate the individual results of this measure into the DAX for other formulas?&amp;nbsp; I need to calculate Profit and when I use this measure it pulls in the total for all the DESC items and applies it to every DESC, when I want it to apply the respective value to each individual DESC.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 21:44:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078430#M107134</guid>
      <dc:creator>Nick-LWI</dc:creator>
      <dc:date>2023-02-13T21:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078485#M107136</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="514180" data-lia-user-login="Nick-LWI" class="lia-mention lia-mention-user"&gt;Nick-LWI&lt;/a&gt;&amp;nbsp; sure&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
DIVIDE (
    SUMX (
        FILTER ( ALL ( 'Table 1' ), 'Table 1'[Desc] = MAX ( 'Table 1'[Desc] ) ),
        'Table 1'[Price] * 'Table 1'[Qty]
    ),
    CALCULATE ( SUM ( 'Table 1'[Qty] ), ALLEXCEPT ( 'Table 1', 'Table 1'[Desc] ) )
)&lt;/LI-CODE&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;</description>
      <pubDate>Mon, 13 Feb 2023 22:44:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078485#M107136</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2023-02-13T22:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078507#M107139</link>
      <description>&lt;P&gt;Thank you smpa01, looks like this solution also gives me the correct weighted average per desc (I ended up using this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&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;SUMX&lt;/SPAN&gt;&lt;SPAN&gt;(Table,Table[Price]*Table[Qty]),&lt;/SPAN&gt;&lt;SPAN&gt;SUMX&lt;/SPAN&gt;&lt;SPAN&gt;(Table,Table[Qty])),&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ALLSELECTED&lt;/SPAN&gt;&lt;SPAN&gt;(Table),Table[Desc]=&lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(Table[Desc])))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;however I'm still unable to use the results that appear in a visual (ie matrix) for further DAX expressions.&amp;nbsp; If you reference the measure in another DAX formula it uses the same value for every single item, and not the individual item's respective value.&amp;nbsp; Using your picture as an example the Total of 33.18 is applied to everything, as opposed to 10 being applied to ABCD, 17.14 applied to DEF, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've exported the matrix to a csv and uploaded it as a table as a workaround, but obviously the data is no longer dynamic, so this is not ideal.&amp;nbsp; Is there any way to reference the results shown in the visual in DAX?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 23:18:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078507#M107139</guid>
      <dc:creator>Nick-LWI</dc:creator>
      <dc:date>2023-02-13T23:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078530#M107141</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="514180" data-lia-user-login="Nick-LWI" class="lia-mention lia-mention-user"&gt;Nick-LWI&lt;/a&gt;&amp;nbsp; can you use the measure I gave you and see if it returns the same value in each cell? &lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 23:52:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078530#M107141</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2023-02-13T23:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078538#M107143</link>
      <description>&lt;P&gt;Yes your measure does return the same value for all cells when applied to a new calculated column.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 00:02:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078538#M107143</guid>
      <dc:creator>Nick-LWI</dc:creator>
      <dc:date>2023-02-14T00:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078544#M107145</link>
      <description>&lt;P&gt;Why are you using a measure for calculated column? They are two different things&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 00:24:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3078544#M107145</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2023-02-14T00:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3079629#M107257</link>
      <description>&lt;P&gt;You didn't mention that you were using a calculated column.&amp;nbsp; If that is the case, then your filter should be using the "Earlier" function, i.e.&amp;nbsp; Filter(Table, desc = Earlier(desc))&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 14:02:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3079629#M107257</guid>
      <dc:creator>BrianConnelly</dc:creator>
      <dc:date>2023-02-14T14:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3079643#M107258</link>
      <description>&lt;P&gt;Your sample data does'nt have enough context for me to understand how your gettting to Profit.&amp;nbsp; Can you provide the rough match so I know what you are attempting to do?&amp;nbsp; Also, if my last answer was your solution to your original question, please mark it as the correct solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 14:07:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3079643#M107258</guid>
      <dc:creator>BrianConnelly</dc:creator>
      <dc:date>2023-02-14T14:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3079672#M107264</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="514180" data-lia-user-login="Nick-LWI" class="lia-mention lia-mention-user"&gt;Nick-LWI&lt;/a&gt;&amp;nbsp; for calculated columns&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column = DIVIDE (
    SUMX (
        FILTER (  'Table 1' , 'Table 1'[Desc] = EARLIER ( 'Table 1'[Desc] ) ),
        'Table 1'[Price] * 'Table 1'[Qty]
    ),
    CALCULATE ( SUM ( 'Table 1'[Qty] ), ALLEXCEPT ( 'Table 1', 'Table 1'[Desc] ) )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 Feb 2023 14:23:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3079672#M107264</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2023-02-14T14:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating weighted avg on rows with shared descriptions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3079930#M107292</link>
      <description>&lt;P&gt;Thank you! This worked.&amp;nbsp; I never would have thought about the EARLIER expression.&amp;nbsp; I appreciate you sticking around and helping me work throught it, I've marked as the solution.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 16:35:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-weighted-avg-on-rows-with-shared-descriptions/m-p/3079930#M107292</guid>
      <dc:creator>Nick-LWI</dc:creator>
      <dc:date>2023-02-14T16:35:08Z</dc:date>
    </item>
  </channel>
</rss>

