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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Jim_PBI
Frequent Visitor

Cumulative total with date table

Hello, 

 

I'm creating a cumulative line chart with total sales for 2 years of data (2021, 2022). I've created a date table as some dates are missing from my sales table, and it was causing an issue when the slicer was applied. The line for 2022 is currently continuing for dates in the future, is there a way to stop the 2022 line at today's date and allow the 2021 line to continue? 

 

I'm using the 'Year' field on the legend to create two lines. 

 

My measure is below: 

 

Cumulative sales =
CALCULATE(
    Sales[Sum_Sales],
    FILTER(
        ALL('Date'[Date]),
        'Date'[Date] <= MAX ('Date'[Date])
    )
)
1 ACCEPTED SOLUTION
Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

@Jim_PBI - you could consider adding a Filter to the Visual so date is less than and equal to Today, or if you need to show the remaining month just with no data instead of straight-line, update your function with something like:

Cumulative sales =
VAR _Today = Today()
RETURN
CALCULATE(
    Sales[Sum_Sales],
    FILTER(
        ALL('Date'[Date]),
        'Date'[Date] <= MAX ('Date'[Date]),
        'Date'[Date] <= _Today
    )
)

OR 

Cumulative sales =
VAR _Today = Today()
RETURN
IF ( MAX( 'Date'[Date] ) <= _Today , 
CALCULATE(
    Sales[Sum_Sales],
    FILTER(
        ALL('Date'[Date]),
        'Date'[Date] <= MAX ('Date'[Date]),
    )
) , BLANK() )

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Jim_PBI ,

 

You could try to add a visula-level filter/measure to limit the dates.

Add a filter to a report in Power BI - Power BI | Microsoft Docs

 

 

 

Best Regards,

Stephen Tao

 

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

Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

@Jim_PBI - you could consider adding a Filter to the Visual so date is less than and equal to Today, or if you need to show the remaining month just with no data instead of straight-line, update your function with something like:

Cumulative sales =
VAR _Today = Today()
RETURN
CALCULATE(
    Sales[Sum_Sales],
    FILTER(
        ALL('Date'[Date]),
        'Date'[Date] <= MAX ('Date'[Date]),
        'Date'[Date] <= _Today
    )
)

OR 

Cumulative sales =
VAR _Today = Today()
RETURN
IF ( MAX( 'Date'[Date] ) <= _Today , 
CALCULATE(
    Sales[Sum_Sales],
    FILTER(
        ALL('Date'[Date]),
        'Date'[Date] <= MAX ('Date'[Date]),
    )
) , BLANK() )

 

Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

@Jim_PBI - you could consider adding a Filter to the Visual so date is less than and equal to Today, or if you need to show the remaining month just with no data instead of straight-line, update your function with something like:

Cumulative sales =
VAR _Today = Today()
RETURN
CALCULATE(
    Sales[Sum_Sales],
    FILTER(
        ALL('Date'[Date]),
        'Date'[Date] <= MAX ('Date'[Date]),
        'Date'[Date] <= _Today
    )
)

OR 

Cumulative sales =
VAR _Today = Today()
RETURN
IF ( MAX( 'Date'[Date] ) <= _Today , 
CALCULATE(
    Sales[Sum_Sales],
    FILTER(
        ALL('Date'[Date]),
        'Date'[Date] <= MAX ('Date'[Date]),
    )
) , BLANK() )

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors