<?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: Rolling 12 months with empty values included in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-12-months-with-empty-values-included/m-p/3572061#M137718</link>
    <description>&lt;P&gt;&lt;SPAN&gt;To calculate a rolling 12-month total in DAX while including empty values, you can modify your DAX formula to use a combination of the &lt;/SPAN&gt;DATESBETWEEN&lt;SPAN&gt;, &lt;/SPAN&gt;CALCULATETABLE&lt;SPAN&gt;, and &lt;/SPAN&gt;SUMX&lt;SPAN&gt; functions. Here's an example DAX formula that you can use:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Rolling12Months =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUMX(&lt;BR /&gt;DATESBETWEEN(&lt;BR /&gt;'YourTable'[Date],&lt;BR /&gt;TODAY() - 12 * 30, -- Adjust the number of days based on your data frequency&lt;BR /&gt;TODAY()&lt;BR /&gt;),&lt;BR /&gt;'YourTable'[YourMeasure] -- Replace 'YourTable' and 'YourMeasure' with your actual table and measure names&lt;BR /&gt;),&lt;BR /&gt;ALL('YourTable'[Date])&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&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;P&gt;This formula calculates the sum of the specified measure ('YourMeasure') for the rolling 12-month period using DATESBETWEEN. The ALL('YourTable'[Date]) part ensures that the context of the date filter is removed, allowing the calculation to include empty values.&lt;/P&gt;&lt;P&gt;Make sure to replace 'YourTable' and 'YourMeasure' with the actual names of your table and measure. Adjust the number of days in the DATESBETWEEN function based on your data frequency (e.g., if your data is at a monthly frequency, use 12; if it's at a daily frequency, use 365).&lt;/P&gt;&lt;P&gt;Note: The exact implementation may depend on your data model and specific requirements, so feel free to adapt the formula accordingly.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&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 class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 07 Dec 2023 09:33:38 GMT</pubDate>
    <dc:creator>123abc</dc:creator>
    <dc:date>2023-12-07T09:33:38Z</dc:date>
    <item>
      <title>Rolling 12 months with empty values included</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-12-months-with-empty-values-included/m-p/3570097#M137647</link>
      <description>&lt;P&gt;hi!&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;I am trying to use below DAX to calculate rolling 12 months. it works fine if there is value, but doesn't work if there is no value. I want that the DAX even calculate with empty values. how can i do that? exemple: the result for 202310 should be 7,17 and NOT 7,82&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2023 09:23:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-12-months-with-empty-values-included/m-p/3570097#M137647</guid>
      <dc:creator>MiTorres76</dc:creator>
      <dc:date>2023-12-06T09:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling 12 months with empty values included</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-12-months-with-empty-values-included/m-p/3572061#M137718</link>
      <description>&lt;P&gt;&lt;SPAN&gt;To calculate a rolling 12-month total in DAX while including empty values, you can modify your DAX formula to use a combination of the &lt;/SPAN&gt;DATESBETWEEN&lt;SPAN&gt;, &lt;/SPAN&gt;CALCULATETABLE&lt;SPAN&gt;, and &lt;/SPAN&gt;SUMX&lt;SPAN&gt; functions. Here's an example DAX formula that you can use:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Rolling12Months =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUMX(&lt;BR /&gt;DATESBETWEEN(&lt;BR /&gt;'YourTable'[Date],&lt;BR /&gt;TODAY() - 12 * 30, -- Adjust the number of days based on your data frequency&lt;BR /&gt;TODAY()&lt;BR /&gt;),&lt;BR /&gt;'YourTable'[YourMeasure] -- Replace 'YourTable' and 'YourMeasure' with your actual table and measure names&lt;BR /&gt;),&lt;BR /&gt;ALL('YourTable'[Date])&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&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;P&gt;This formula calculates the sum of the specified measure ('YourMeasure') for the rolling 12-month period using DATESBETWEEN. The ALL('YourTable'[Date]) part ensures that the context of the date filter is removed, allowing the calculation to include empty values.&lt;/P&gt;&lt;P&gt;Make sure to replace 'YourTable' and 'YourMeasure' with the actual names of your table and measure. Adjust the number of days in the DATESBETWEEN function based on your data frequency (e.g., if your data is at a monthly frequency, use 12; if it's at a daily frequency, use 365).&lt;/P&gt;&lt;P&gt;Note: The exact implementation may depend on your data model and specific requirements, so feel free to adapt the formula accordingly.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&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 class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 07 Dec 2023 09:33:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-12-months-with-empty-values-included/m-p/3572061#M137718</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-12-07T09:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling 12 months with empty values included</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-12-months-with-empty-values-included/m-p/3572110#M137726</link>
      <description>&lt;P&gt;Hi, your code looks good enough, I think you are only missing the blank values in&amp;nbsp; &lt;SPAN&gt;[Antal mp heltapp]. So I would suggest adjusting that part to:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE (
    AVERAGEX (
        VALUES ( DimDate[Period] ),
        IF ( ISBLANK ( [Antal mp heltapp] ), 0, [Antal mp heltapp] )
    ),&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;To explain, you are iterating every item in the values column, but if&amp;nbsp;&lt;SPAN&gt;[Antal mp heltapp] is blank the whole item is skipped. So if you have 30 items in the values column that have only 29 corresponding non blank in [Antal mp heltapp], it will give you the total of&amp;nbsp;[Antal mp heltapp] over values, divided by 29 in stead of 30. This explains exactly why your result is higher than it actually is.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 10:00:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-12-months-with-empty-values-included/m-p/3572110#M137726</guid>
      <dc:creator>ray_codex</dc:creator>
      <dc:date>2023-12-07T10:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling 12 months with empty values included</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-12-months-with-empty-values-included/m-p/3572471#M137739</link>
      <description>&lt;P&gt;hi ray_codex!&lt;BR /&gt;Thanks for your reply, but after making those changes it didn't turn out what I was hoping for. I get the same result as Count of Mätpunktsnummer. The average of 202309 is correct as it takes the sum of 202309-202210 = 90/12 = 7.5.&lt;BR /&gt;the average of 202310 should be&lt;BR /&gt;202310-202211 =86/12 = 7.17&lt;/P&gt;&lt;P&gt;and so on&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 12:50:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-12-months-with-empty-values-included/m-p/3572471#M137739</guid>
      <dc:creator>MiTorres76</dc:creator>
      <dc:date>2023-12-07T12:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling 12 months with empty values included</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-12-months-with-empty-values-included/m-p/3572486#M137740</link>
      <description>&lt;P&gt;hi 123abc!&lt;BR /&gt;thanks for your reply, but with your DAX I get the sum of the last 12 months. I would like to calculate the average. for example the average for 202309 is correct as it takes the sum of 202309-202210 = 90/12 = 7.5.&lt;BR /&gt;the average of 202310 should be 202310-202211 =86/12 = 7.17&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 12:59:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-12-months-with-empty-values-included/m-p/3572486#M137740</guid>
      <dc:creator>MiTorres76</dc:creator>
      <dc:date>2023-12-07T12:59:43Z</dc:date>
    </item>
  </channel>
</rss>

