Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
JB_AT
Helper III
Helper III

Calculate Values to a selected Date

I hope you can help

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.

 

The below measure partially works, but when added to a visual, it shows data after the selected date in the slicer. 

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.

On top of that I want to calculate all open invoices up to the selected date in the slicer. 

Please note I am using a between date slicer, set to After, so the StartDate is only changable, 

 

Any suggestions on how I can prevent the result appearing after the selected date in the slicer?

 

Thanking you in adavnce

Customer Invoice - Open Amount To Selected Date = 
VAR _SelectedDate = MAX ( 'DIM Date'[Date] )
RETURN
    CALCULATE (
        SUM ( 'CustomerInvoices'[Open Amount] ),
        'CustomerInvoices'[DueDate] <= _SelectedDate,
        'CustomerInvoices'[ValidFrom] <= _SelectedDate,
        'CustomerInvoices'[ValidUntil] > _SelectedDate,
        REMOVEFILTERS( 'DIM Date'[Date] )
    )



 

3 REPLIES 3
Anonymous
Not applicable

Hi @JB_AT ,

Based on the description, try deleting a relationship between two date columns and removing the REMOVEFILTERS function.

If a relationship exists, the date selected by the slicer directly affects the date column of the other table.

Besides, can you provide the sample data? What is the ValidUntil column?

 

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

JB_AT
Helper III
Helper III

 @DataNinja777 

 

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

 

Thanks

DataNinja777
Super User
Super User

Hi @JB_AT ,

 

Here’s an adjusted version of your measure:

Customer Invoice - Open Amount To Selected Date = 
VAR _SelectedDate = MAX('DIM Date'[Date])
RETURN
    CALCULATE(
        SUM('CustomerInvoices'[Open Amount]),
        'CustomerInvoices'[DueDate] <= _SelectedDate, 
        'CustomerInvoices'[ValidFrom] <= _SelectedDate,
        OR(
            'CustomerInvoices'[ValidUntil] >= _SelectedDate,
            ISBLANK('CustomerInvoices'[ValidUntil])
        ),
        REMOVEFILTERS('DIM Date')
    )

I added an OR condition to account for cases where the ValidUntil date might be blank (indicating the invoice is still valid).

 

Using REMOVEFILTERS('DIM Date') ensures that the measure operates correctly within the context of the slicer without inheriting conflicting filters from the visual.

 

The measure now takes a "snapshot" by ensuring that only invoices valid as of the selected date are included.

 

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!

 

Best regards

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.