<?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: Problem with DAX query calculating an average value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511539#M134754</link>
    <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="632063" data-lia-user-login="FrankWe" class="lia-mention lia-mention-user"&gt;FrankWe&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Constant Average Line is a standard built-in feature, check this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-analytics-pane" target="_blank"&gt;https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-analytics-pane&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Nov 2023 09:15:15 GMT</pubDate>
    <dc:creator>FreemanZ</dc:creator>
    <dc:date>2023-11-02T09:15:15Z</dc:date>
    <item>
      <title>Problem with DAX query calculating an average value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511445#M134747</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem to create a DAX measure calculating an average value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a combined bar and line chart. The bars are showing the total numbers of rows in a table "visits" per month on the X axis. So far so good. Now I inserted a date slicer tot select a date range on yearmonth level. The yearmonth values are taken from a calendar table. using the slicer filters the data to the selected time period.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now my problem:&amp;nbsp; I would like to have a horizontal line in the chart showing the average of visits based on the selected time period. That means when I have a total of 600 visits in 5 months the horizontal line should be at a value of 120 for each month.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I know how to get the start and end values of the slicer and also the total number of visits in the selected time period. But I have no idea how to get this horizontal line showing the same average value in each month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Frank&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 08:41:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511445#M134747</guid>
      <dc:creator>FrankWe</dc:creator>
      <dc:date>2023-11-02T08:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with DAX query calculating an average value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511539#M134754</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="632063" data-lia-user-login="FrankWe" class="lia-mention lia-mention-user"&gt;FrankWe&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Constant Average Line is a standard built-in feature, check this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-analytics-pane" target="_blank"&gt;https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-analytics-pane&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 09:15:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511539#M134754</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-11-02T09:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with DAX query calculating an average value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511596#M134756</link>
      <description>&lt;P&gt;Hi, thank you for this info, but I think the constant average line is not available for a stacked bar chart as I need this to show the different visit types in the bar. Sorry for not mentioning that. When I look into the analytics pane there is now average bar available.&lt;/P&gt;&lt;P&gt;The chart should look like the one below. The red line is the average line and it should change every time when I change the time period in the date slicer.&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 09:34:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511596#M134756</guid>
      <dc:creator>FrankWe</dc:creator>
      <dc:date>2023-11-02T09:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with DAX query calculating an average value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511710#M134765</link>
      <description>&lt;P&gt;I have created something similar, but you should be able to adjust to your own measures and date dimension table. crucial&amp;nbsp; is the use of ALLSELECTED to give you the filter/slicer context:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;avg montly visits = CALCULATE(AVERAGEX(VALUES('dim_date'[month_year]),[# visits]), ALLSELECTED('dim_date'))&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 10:28:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511710#M134765</guid>
      <dc:creator>sjoerdvn</dc:creator>
      <dc:date>2023-11-02T10:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with DAX query calculating an average value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511814#M134773</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="226664" data-lia-user-login="sjoerdvn" class="lia-mention lia-mention-user"&gt;sjoerdvn&lt;/a&gt;: Hi, thank your this. I tried to implement this, but the result is that the line is showing me the total number of visits in the selected time period and not the average&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My measure looks like this now:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;AverageVisits2&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&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;AVERAGEX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;VALUES&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Calendar'&lt;/SPAN&gt;&lt;SPAN&gt;[MonthYear]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;COUNT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Visits&lt;/SPAN&gt;&lt;SPAN&gt;[VisitID]&lt;/SPAN&gt;&lt;SPAN&gt;)),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ALLSELECTED&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Calendar'&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;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;What is wrong whit this?&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 02 Nov 2023 11:09:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511814#M134773</guid>
      <dc:creator>FrankWe</dc:creator>
      <dc:date>2023-11-02T11:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with DAX query calculating an average value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511926#M134781</link>
      <description>&lt;P&gt;since you're not using a measure, you have to add a calculate to force the context.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR AverageVisits2 = 
CALCULATE(
    AVERAGEX(
        VALUES('Calendar'[MonthYear]),
        CALCULATE(COUNT(Visits[VisitID])))
   ,ALLSELECTED('Calendar')
)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 02 Nov 2023 12:01:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511926#M134781</guid>
      <dc:creator>sjoerdvn</dc:creator>
      <dc:date>2023-11-02T12:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with DAX query calculating an average value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511947#M134782</link>
      <description>&lt;P&gt;@&lt;SPAN&gt;sjoerdvn: Many thanks for your help. You are my hero&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt; And it shows me that I will have to learn so much more to understand more of the DAX functionality&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;BR /&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 02 Nov 2023 12:12:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-DAX-query-calculating-an-average-value/m-p/3511947#M134782</guid>
      <dc:creator>FrankWe</dc:creator>
      <dc:date>2023-11-02T12:12:10Z</dc:date>
    </item>
  </channel>
</rss>

