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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
EdK99
Frequent Visitor

Sum rows from the first date until the max selected date in a slicer

Hello,

 

I've been searching high and low for a solution for this and I still can't find a way to make it work.

I have a table that contains sales values, the columns are as follow:

Sales Person

Date

Sales Amount

 

and I have a slicer with dates that are coming from a date table.

 

My goal is to create a measure that sums up ALL the sales amount until the max selected date. so for example, if the user selected the dates from the slicer as below:

EdK99_0-1695729643772.png

 

The measure would sum up all the sales amount from 2020 until the max selected month in 2023

 

 

Any support would be appreciated, and I am happy to answer any quesitons to clarify the issue.

3 REPLIES 3
jdbuchanan71
Super User
Super User

Yes, but you will have to add a dates table to your model.  Then you use the dates table in your slicer and you can write the measure like this.

Total To Date = 
VAR _Max = MAX ( DATES[Date] )
RETURN
CALCULATE ( SUM ( YourTable[Amount] ), DATES[Date] <= _Max )
jdbuchanan71
Super User
Super User

I am assuming you are going to want to have a filter on sales person still work so try a filter like this.

Total To Date = 
VAR _Max = MAX ( YourTable[Date] )
RETURN
CALCULATE ( SUM ( YourTable[Amount] ), ALLEXCEPT ( YourTable, YourTable[Sales Person] ),  YourTable[Date] <= _Max )

is there any other way of doing this? using ALLEXFCEPT prevents me from adding data from other tables to the visuals.

the visual I'm using is a matrix, it pulls two rows from dimensions tables that are connect to all the other tables, the values in the matrix are the measures and one of the measures is the sales amount. If I use ALLEXCEPT, I can't use data from other tables in the visual.

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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