<?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: Calculate Values to a selected Date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Values-to-a-selected-Date/m-p/4246668#M168127</link>
    <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="626251" data-lia-user-login="JB_AT" class="lia-mention lia-mention-user"&gt;JB_AT&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here’s an adjusted version of your measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Customer Invoice - Open Amount To Selected Date = 
VAR _SelectedDate = MAX('DIM Date'[Date])
RETURN
    CALCULATE(
        SUM('CustomerInvoices'[Open Amount]),
        'CustomerInvoices'[DueDate] &amp;lt;= _SelectedDate, 
        'CustomerInvoices'[ValidFrom] &amp;lt;= _SelectedDate,
        OR(
            'CustomerInvoices'[ValidUntil] &amp;gt;= _SelectedDate,
            ISBLANK('CustomerInvoices'[ValidUntil])
        ),
        REMOVEFILTERS('DIM Date')
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;I added an OR condition to account for cases where the ValidUntil date might be blank (indicating the invoice is still valid).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Using REMOVEFILTERS('DIM Date') ensures that the measure operates correctly within the context of the slicer without inheriting conflicting filters from the visual.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The measure now takes a "snapshot" by ensuring that only invoices valid as of the selected date are included.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should prevent the result from showing data beyond the selected date while correctly aggregating open invoices up to and including that date. Let me know if this version resolves your issue!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;</description>
    <pubDate>Thu, 17 Oct 2024 13:45:38 GMT</pubDate>
    <dc:creator>DataNinja777</dc:creator>
    <dc:date>2024-10-17T13:45:38Z</dc:date>
    <item>
      <title>Calculate Values to a selected Date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Values-to-a-selected-Date/m-p/4246570#M168124</link>
      <description>&lt;P&gt;I hope you can help&lt;BR /&gt;&lt;BR /&gt;I have the requirement that when a date is selected in the Date slicer, that I calculate the Invoice data up to and including that date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below measure partially works, but when added to a visual, it shows data after the selected date in the slicer.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The ValidFrom and ValidTo are there to show changes within the Invoice, so the invoice could have mulitiple rows. I want the selected date in the slicer to filter the table where is falls into the filters I set below. Basically taking a snapshot of the data the way it was on the selected date.&lt;BR /&gt;&lt;BR /&gt;On top of that I want to calculate all open invoices up to the selected date in the slicer.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Please note I am using a between date slicer, set to After, so the StartDate is only changable,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions on how I can prevent the result appearing after the selected date in the slicer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanking you in adavnce&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Customer Invoice - Open Amount To Selected Date = 
VAR _SelectedDate = MAX ( 'DIM Date'[Date] )
RETURN
    CALCULATE (
        SUM ( 'CustomerInvoices'[Open Amount] ),
        'CustomerInvoices'[DueDate] &amp;lt;= _SelectedDate,
        'CustomerInvoices'[ValidFrom] &amp;lt;= _SelectedDate,
        'CustomerInvoices'[ValidUntil] &amp;gt; _SelectedDate,
        REMOVEFILTERS( 'DIM Date'[Date] )
    )&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 12:53:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Values-to-a-selected-Date/m-p/4246570#M168124</guid>
      <dc:creator>JB_AT</dc:creator>
      <dc:date>2024-10-17T12:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Values to a selected Date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Values-to-a-selected-Date/m-p/4246668#M168127</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="626251" data-lia-user-login="JB_AT" class="lia-mention lia-mention-user"&gt;JB_AT&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here’s an adjusted version of your measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Customer Invoice - Open Amount To Selected Date = 
VAR _SelectedDate = MAX('DIM Date'[Date])
RETURN
    CALCULATE(
        SUM('CustomerInvoices'[Open Amount]),
        'CustomerInvoices'[DueDate] &amp;lt;= _SelectedDate, 
        'CustomerInvoices'[ValidFrom] &amp;lt;= _SelectedDate,
        OR(
            'CustomerInvoices'[ValidUntil] &amp;gt;= _SelectedDate,
            ISBLANK('CustomerInvoices'[ValidUntil])
        ),
        REMOVEFILTERS('DIM Date')
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;I added an OR condition to account for cases where the ValidUntil date might be blank (indicating the invoice is still valid).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Using REMOVEFILTERS('DIM Date') ensures that the measure operates correctly within the context of the slicer without inheriting conflicting filters from the visual.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The measure now takes a "snapshot" by ensuring that only invoices valid as of the selected date are included.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should prevent the result from showing data beyond the selected date while correctly aggregating open invoices up to and including that date. Let me know if this version resolves your issue!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 13:45:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Values-to-a-selected-Date/m-p/4246668#M168127</guid>
      <dc:creator>DataNinja777</dc:creator>
      <dc:date>2024-10-17T13:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Values to a selected Date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Values-to-a-selected-Date/m-p/4247604#M168172</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="608865" data-lia-user-login="DataNinja777" class="lia-mention lia-mention-user"&gt;DataNinja777&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately the measure still returns values after the selected date. I forgot to mention that I have an active relationship between the Date and MaxDueDate columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 05:06:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Values-to-a-selected-Date/m-p/4247604#M168172</guid>
      <dc:creator>JB_AT</dc:creator>
      <dc:date>2024-10-18T05:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Values to a selected Date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Values-to-a-selected-Date/m-p/4250518#M168288</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="626251" data-lia-user-login="JB_AT" class="lia-mention lia-mention-user"&gt;JB_AT&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Based on the description, try deleting a relationship between two date columns and removing the REMOVEFILTERS function.&lt;/P&gt;
&lt;P&gt;If a relationship exists, the date selected by the slicer directly affects the date column of the other table.&lt;/P&gt;
&lt;P&gt;Besides, can you provide the sample data? What is the ValidUntil column?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 09:43:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Values-to-a-selected-Date/m-p/4250518#M168288</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-21T09:43:10Z</dc:date>
    </item>
  </channel>
</rss>

