<?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 Calculate the Average using a Dimension column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-Average-using-a-Dimension-column/m-p/3095716#M108621</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to calculate the Average of a dimension attribute based on a Fact table. The following are the tables (simplified, eg Category doesn't actually live in the Fact table but there to visualise what I'm trying to do)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dimension table is:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Fact table is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;What I'd like is to calculate the average AnswerID over all the rows in the Fact table, I've tried to create a measure but all it's doing is calculating the average over the distinct AnswerID values, not over each AnswerID that would be linked to the fact table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Average Answer = CALCULATE(AVERAGE(DimAnswer[AnswerID]),CROSSFILTER(DimAnswer[AnswerKey],FactAnswer[AnswerKey],BOTH))&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the result is incorrect as it's just calculating the average for each distinct AnswerID.&amp;nbsp; In the case of Category A, there are 7 rows in the fact table, when the AnswerID for each of the 7 rows is add up it totals 20.&amp;nbsp; So 20/7 = 2.8.&amp;nbsp; But what my measure is doing is just taking the unique AnswerIDs which would be 2,4,6, then dividing by the distinct number of AnswerID which is 3.&amp;nbsp; So 12/3 = 4.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone point me towards how I would do the Average by taking each row in the Fact table, getting the AnswerID and then doing the average over this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;</description>
    <pubDate>Thu, 23 Feb 2023 15:12:34 GMT</pubDate>
    <dc:creator>AndyDDC</dc:creator>
    <dc:date>2023-02-23T15:12:34Z</dc:date>
    <item>
      <title>Calculate the Average using a Dimension column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-Average-using-a-Dimension-column/m-p/3095716#M108621</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to calculate the Average of a dimension attribute based on a Fact table. The following are the tables (simplified, eg Category doesn't actually live in the Fact table but there to visualise what I'm trying to do)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dimension table is:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Fact table is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;What I'd like is to calculate the average AnswerID over all the rows in the Fact table, I've tried to create a measure but all it's doing is calculating the average over the distinct AnswerID values, not over each AnswerID that would be linked to the fact table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Average Answer = CALCULATE(AVERAGE(DimAnswer[AnswerID]),CROSSFILTER(DimAnswer[AnswerKey],FactAnswer[AnswerKey],BOTH))&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the result is incorrect as it's just calculating the average for each distinct AnswerID.&amp;nbsp; In the case of Category A, there are 7 rows in the fact table, when the AnswerID for each of the 7 rows is add up it totals 20.&amp;nbsp; So 20/7 = 2.8.&amp;nbsp; But what my measure is doing is just taking the unique AnswerIDs which would be 2,4,6, then dividing by the distinct number of AnswerID which is 3.&amp;nbsp; So 12/3 = 4.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone point me towards how I would do the Average by taking each row in the Fact table, getting the AnswerID and then doing the average over this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 15:12:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-Average-using-a-Dimension-column/m-p/3095716#M108621</guid>
      <dc:creator>AndyDDC</dc:creator>
      <dc:date>2023-02-23T15:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Average using a Dimension column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-Average-using-a-Dimension-column/m-p/3095734#M108625</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="265587" data-lia-user-login="AndyDDC" class="lia-mention lia-mention-user"&gt;AndyDDC&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Please use&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;AverageMeasure =
AVERAGEX ( Fact, RELATED ( Dim[AnswerID] ) )&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 23 Feb 2023 15:18:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-Average-using-a-Dimension-column/m-p/3095734#M108625</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-02-23T15:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Average using a Dimension column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-Average-using-a-Dimension-column/m-p/3096187#M108656</link>
      <description>&lt;P&gt;Brilliant, thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 17:54:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-Average-using-a-Dimension-column/m-p/3096187#M108656</guid>
      <dc:creator>AndyDDC</dc:creator>
      <dc:date>2023-02-23T17:54:59Z</dc:date>
    </item>
  </channel>
</rss>

