<?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: Average YoY changes by Year Selection in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-YoY-changes-by-Year-Selection/m-p/3432773#M130161</link>
    <description>&lt;P&gt;To calculate the average year-over-year (YoY) changes based on the year selection in Power BI and display it as a single DAX formula, you can use the following approach. You'll need to create a measure that calculates the YoY change for each year, and then another measure to calculate the average of these YoY changes. Here's how you can do it:&lt;/P&gt;&lt;P&gt;Step 1: Create a Measure for YoY Changes&lt;/P&gt;&lt;P&gt;First, create a measure that calculates the YoY change for each year. You can use the following DAX formula for this measure:&lt;/P&gt;&lt;P&gt;```DAX&lt;BR /&gt;YoY Change =&lt;BR /&gt;VAR SelectedYear = MAX('All '[Start Date].[Year])&lt;BR /&gt;VAR PreviousYear = SelectedYear - 1&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM('Scores by Questions'[Scores Changes YoY]),&lt;BR /&gt;'All '[Start Date].[Year] = SelectedYear&lt;BR /&gt;) - CALCULATE(&lt;BR /&gt;SUM('Scores by Questions'[Scores Changes YoY]),&lt;BR /&gt;'All '[Start Date].[Year] = PreviousYear&lt;BR /&gt;)&lt;BR /&gt;```&lt;/P&gt;&lt;P&gt;This measure calculates the difference between the sum of "Scores Changes YoY" for the selected year and the previous year.&lt;/P&gt;&lt;P&gt;Step 2: Create a Measure for Average YoY Changes&lt;/P&gt;&lt;P&gt;Now, create a measure to calculate the average YoY change based on the year selection. You can use the following DAX formula for this measure:&lt;/P&gt;&lt;P&gt;```DAX&lt;BR /&gt;Average YoY Change =&lt;BR /&gt;VAR SelectedYear = MAX('All '[Start Date].[Year])&lt;BR /&gt;VAR TotalYears = COUNTROWS(ALL('All '[Start Date].[Year]))&lt;BR /&gt;RETURN&lt;BR /&gt;DIVIDE(&lt;BR /&gt;SUMX(&lt;BR /&gt;VALUES('All '[Start Date].[Year]),&lt;BR /&gt;[YoY Change]&lt;BR /&gt;),&lt;BR /&gt;TotalYears&lt;BR /&gt;)&lt;BR /&gt;```&lt;/P&gt;&lt;P&gt;This measure calculates the sum of YoY changes for all years and then divides it by the total number of years.&lt;/P&gt;&lt;P&gt;Step 3: Display the Average YoY Change&lt;/P&gt;&lt;P&gt;Now, you can use the "Average YoY Change" measure in your visualization to display the average YoY change based on the selected year. When you select a specific year in your slicer or filter, this measure will dynamically calculate and display the correct average YoY change.&lt;/P&gt;&lt;P&gt;By following these steps, you can compute the average YoY changes as a single DAX formula and display it based on the year selection in your Power BI report.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Sep 2023 10:43:43 GMT</pubDate>
    <dc:creator>123abc</dc:creator>
    <dc:date>2023-09-15T10:43:43Z</dc:date>
    <item>
      <title>Average YoY changes by Year Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-YoY-changes-by-Year-Selection/m-p/3429919#M130007</link>
      <description>&lt;P&gt;Hi, I wanted to obtain the average YoY changes based on the year selection, however, the average function only accepts a column reference as an argument (the error displayed).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;1st Column:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Average Score this year = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&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;SPA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lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;U&gt;&lt;STRONG&gt;3rd Column:&lt;/STRONG&gt;&lt;/U&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;SPAN&gt;Scores Changes YoY = &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Average Scores Last Year]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;BLANK&lt;/SPAN&gt;&lt;SPAN&gt;(), &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Average Score this year]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;BLANK&lt;/SPAN&gt;&lt;SPAN&gt;(),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;Average Score this year]-&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;Average Scores Last Year])&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The visualization that I put up as per below:-&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to add one text statement with the value to display the Average Scores changes based on the year selection. The formula should be =Average([Scores Changes YoY]/&lt;SPAN&gt;'All '&lt;/SPAN&gt;&lt;SPAN&gt;[Start Date]&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;[Year]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If select Year 2022, then calculate (0.38-0.47+0.01)/3 years = -0.027&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if select Year 2021, then calculate (0.38-0.47)/2 years = -0.04&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My question is:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;i) How do I compute the Dax formula correctly to display the correct Average Scores changes data based on year selection?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ii) I separate the Dax formula into different 3-4 columns due to not being very well versed in this, how do I combine/compute into one Dax formula?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you very much for your help!&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 14 Sep 2023 04:17:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-YoY-changes-by-Year-Selection/m-p/3429919#M130007</guid>
      <dc:creator>AKath_12</dc:creator>
      <dc:date>2023-09-14T04:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Average YoY changes by Year Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-YoY-changes-by-Year-Selection/m-p/3432773#M130161</link>
      <description>&lt;P&gt;To calculate the average year-over-year (YoY) changes based on the year selection in Power BI and display it as a single DAX formula, you can use the following approach. You'll need to create a measure that calculates the YoY change for each year, and then another measure to calculate the average of these YoY changes. Here's how you can do it:&lt;/P&gt;&lt;P&gt;Step 1: Create a Measure for YoY Changes&lt;/P&gt;&lt;P&gt;First, create a measure that calculates the YoY change for each year. You can use the following DAX formula for this measure:&lt;/P&gt;&lt;P&gt;```DAX&lt;BR /&gt;YoY Change =&lt;BR /&gt;VAR SelectedYear = MAX('All '[Start Date].[Year])&lt;BR /&gt;VAR PreviousYear = SelectedYear - 1&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM('Scores by Questions'[Scores Changes YoY]),&lt;BR /&gt;'All '[Start Date].[Year] = SelectedYear&lt;BR /&gt;) - CALCULATE(&lt;BR /&gt;SUM('Scores by Questions'[Scores Changes YoY]),&lt;BR /&gt;'All '[Start Date].[Year] = PreviousYear&lt;BR /&gt;)&lt;BR /&gt;```&lt;/P&gt;&lt;P&gt;This measure calculates the difference between the sum of "Scores Changes YoY" for the selected year and the previous year.&lt;/P&gt;&lt;P&gt;Step 2: Create a Measure for Average YoY Changes&lt;/P&gt;&lt;P&gt;Now, create a measure to calculate the average YoY change based on the year selection. You can use the following DAX formula for this measure:&lt;/P&gt;&lt;P&gt;```DAX&lt;BR /&gt;Average YoY Change =&lt;BR /&gt;VAR SelectedYear = MAX('All '[Start Date].[Year])&lt;BR /&gt;VAR TotalYears = COUNTROWS(ALL('All '[Start Date].[Year]))&lt;BR /&gt;RETURN&lt;BR /&gt;DIVIDE(&lt;BR /&gt;SUMX(&lt;BR /&gt;VALUES('All '[Start Date].[Year]),&lt;BR /&gt;[YoY Change]&lt;BR /&gt;),&lt;BR /&gt;TotalYears&lt;BR /&gt;)&lt;BR /&gt;```&lt;/P&gt;&lt;P&gt;This measure calculates the sum of YoY changes for all years and then divides it by the total number of years.&lt;/P&gt;&lt;P&gt;Step 3: Display the Average YoY Change&lt;/P&gt;&lt;P&gt;Now, you can use the "Average YoY Change" measure in your visualization to display the average YoY change based on the selected year. When you select a specific year in your slicer or filter, this measure will dynamically calculate and display the correct average YoY change.&lt;/P&gt;&lt;P&gt;By following these steps, you can compute the average YoY changes as a single DAX formula and display it based on the year selection in your Power BI report.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2023 10:43:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-YoY-changes-by-Year-Selection/m-p/3432773#M130161</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-09-15T10:43:43Z</dc:date>
    </item>
  </channel>
</rss>

