<?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 SUM data from the selected date and the date before the selected date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-data-from-the-selected-date-and-the-date-before-the-selected/m-p/1997916#M44324</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I choose a date i want to SUM values in a column for that date and for the day before the selected date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the same table as the date filter I also have a DATETIME column which shows every hour of the day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also need to filter so I only get data from after 22:00 from the day before and before 06:00 the day after. That means if I choose 03.07.2021 I want to SUM data from the period 02.07.2021 22:00 - 03.07.2021 06:00.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The date filter is from a table called "DateTime" and the column is called "Date" (&lt;SPAN&gt;DateTime[Date])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The DATETIME column is also in the table "Datetime"&amp;nbsp;(DateTime[DateTime])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The column I want to SUM is from a table called "OM44a" and the column is named "&lt;SPAN&gt;# Packed *" (&lt;/SPAN&gt;&lt;SPAN&gt;OM44a[# Packed *])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the Date table I also have a column for TIME and column for HOUR.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Rickard&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Aug 2021 13:04:23 GMT</pubDate>
    <dc:creator>andersonrickard</dc:creator>
    <dc:date>2021-08-04T13:04:23Z</dc:date>
    <item>
      <title>SUM data from the selected date and the date before the selected date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-data-from-the-selected-date-and-the-date-before-the-selected/m-p/1997916#M44324</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I choose a date i want to SUM values in a column for that date and for the day before the selected date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the same table as the date filter I also have a DATETIME column which shows every hour of the day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also need to filter so I only get data from after 22:00 from the day before and before 06:00 the day after. That means if I choose 03.07.2021 I want to SUM data from the period 02.07.2021 22:00 - 03.07.2021 06:00.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The date filter is from a table called "DateTime" and the column is called "Date" (&lt;SPAN&gt;DateTime[Date])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The DATETIME column is also in the table "Datetime"&amp;nbsp;(DateTime[DateTime])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The column I want to SUM is from a table called "OM44a" and the column is named "&lt;SPAN&gt;# Packed *" (&lt;/SPAN&gt;&lt;SPAN&gt;OM44a[# Packed *])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the Date table I also have a column for TIME and column for HOUR.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Rickard&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 13:04:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-data-from-the-selected-date-and-the-date-before-the-selected/m-p/1997916#M44324</guid>
      <dc:creator>andersonrickard</dc:creator>
      <dc:date>2021-08-04T13:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: SUM data from the selected date and the date before the selected date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-data-from-the-selected-date-and-the-date-before-the-selected/m-p/1997937#M44328</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="223181" data-lia-user-login="andersonrickard" class="lia-mention lia-mention-user"&gt;andersonrickard&lt;/a&gt;&amp;nbsp;A lot to unpack here and hard to exactly visualize without sample data. With your first request, it would be along the lines of:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure =
  VAR __SelectedDate = MAX('Table'[Date])
  VAR __Previous = __SelectedDate - 1
RETURN
  SUMX(FILTER(ALL('Table'),[Date] &amp;gt;= __Previous &amp;amp;&amp;amp; [Date] &amp;lt;= __SelectedDate), [# Packed *])&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 04 Aug 2021 13:22:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-data-from-the-selected-date-and-the-date-before-the-selected/m-p/1997937#M44328</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-04T13:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: SUM data from the selected date and the date before the selected date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-data-from-the-selected-date-and-the-date-before-the-selected/m-p/1999357#M44388</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;Thank you for your answer. I also want to thank you for all your answers in a lot of other threads. You helped me a lot since i started with Power BI.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Your formula worked to give me the SUM from the selected date and the day before&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure 4 = 
  VAR __SelectedDate = MAX(DateTime[Date])
  VAR __Previous = __SelectedDate - 1
RETURN
  SUMX(FILTER(ALL(DateTime);DateTime[Date] &amp;gt;= __Previous &amp;amp;&amp;amp; DateTime[Date] &amp;lt;= __SelectedDate); [Antall DSP])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Now I need to get the formula to only show values from before 06:00 on the selected date and after 22:00 the day before. Is this possible? Any ideas?&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Rickard&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 06:41:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-data-from-the-selected-date-and-the-date-before-the-selected/m-p/1999357#M44388</guid>
      <dc:creator>andersonrickard</dc:creator>
      <dc:date>2021-08-05T06:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: SUM data from the selected date and the date before the selected date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-data-from-the-selected-date-and-the-date-before-the-selected/m-p/1999719#M44395</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;I found a workaround that works. It isn't pretty.&lt;/P&gt;&lt;P&gt;I did a new column showing only TIME then I did multiple measures to that table and made them work in the formula you gave me.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Antall DSP2 = CALCULATE(SUM(OM44a[# Packed *]);OM44a[Time] &amp;lt; TIMEVALUE("06:00"))
Antall DSP3 = CALCULATE(SUM(OM44a[# Packed *]);OM44a[Time] &amp;gt;= TIMEVALUE("22:00"))

Measure 5 = 
  VAR __SelectedDate = MAX(DateTime[Date])
  VAR __Previous = __SelectedDate - 1
RETURN
  SUMX(FILTER(ALL(DateTime);DateTime[Date] = __SelectedDate); [Antall DSP2])+SUMX(FILTER(ALL(DateTime);DateTime[Date] = __Previous); [Antall DSP3])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 08:56:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-data-from-the-selected-date-and-the-date-before-the-selected/m-p/1999719#M44395</guid>
      <dc:creator>andersonrickard</dc:creator>
      <dc:date>2021-08-05T08:56:08Z</dc:date>
    </item>
  </channel>
</rss>

