<?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: Get the average sales value based on last 7 days but if there are no sales there is no entry in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-average-sales-value-based-on-last-7-days-but-if-there/m-p/3746948#M146146</link>
    <description>&lt;P&gt;I forgot to mention, I have a calendar table connected to this sales table&lt;/P&gt;</description>
    <pubDate>Wed, 06 Mar 2024 19:39:30 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-03-06T19:39:30Z</dc:date>
    <item>
      <title>Get the average sales value based on last 7 days but if there are no sales there is no entry</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-average-sales-value-based-on-last-7-days-but-if-there/m-p/3746947#M146145</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I attempting to get the average sales for the last 7 days of a sales table like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Item&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;QTY&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AA&lt;/TD&gt;&lt;TD&gt;1/1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AA&lt;/TD&gt;&lt;TD&gt;1/2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AA&lt;/TD&gt;&lt;TD&gt;1/4&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AA&lt;/TD&gt;&lt;TD&gt;1/6&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem i'm running into is that If you Average() or Averagex() and use whichever date filter, you get the average of values that exist. Ideally, I would want the average including the 0 sales on 1/5,1/7 and 1/3 but those transaction don't appear in my table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would want a dax expression to result to this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Item&lt;/TD&gt;&lt;TD&gt;7 Day Average&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AA&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 06 Mar 2024 19:37:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-average-sales-value-based-on-last-7-days-but-if-there/m-p/3746947#M146145</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-06T19:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Get the average sales value based on last 7 days but if there are no sales there is no entry</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-average-sales-value-based-on-last-7-days-but-if-there/m-p/3746948#M146146</link>
      <description>&lt;P&gt;I forgot to mention, I have a calendar table connected to this sales table&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 19:39:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-average-sales-value-based-on-last-7-days-but-if-there/m-p/3746948#M146146</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-06T19:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Get the average sales value based on last 7 days but if there are no sales there is no entry</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-average-sales-value-based-on-last-7-days-but-if-there/m-p/3747123#M146148</link>
      <description>&lt;P&gt;Found a solution!&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;SPAN&gt;7 Day Moving Average = &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VAR SelectedDate = MAX(Calendar[Date]) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VAR StartDate = SelectedDate - 6 VAR TotalSales = CALCULATE ( SUM ( Sales[Amount] ), DATESINPERIOD ( Calendar[Date], StartDate, SelectedDate, DAY ) ) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VAR TotalDays = COUNTROWS ( DATESINPERIOD ( Calendar[Date], StartDate, SelectedDate, DAY ) ) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;RETURN DIVIDE ( TotalSales, TotalDays, 0 )&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 21:44:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-the-average-sales-value-based-on-last-7-days-but-if-there/m-p/3747123#M146148</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-06T21:44:13Z</dc:date>
    </item>
  </channel>
</rss>

