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
WM117
Frequent Visitor

cumulative measure in line chart

Hi everybody,

 

I'm stuck with an issue that is bothering me for quite some time now. The orange line in the line chart below represents the cumulative written hours n a project. The hours are registered untill july, after that there is no data. As you see, the line continous untill the end of the year. I want to create a dax measure (or another solution if that's easier), that cuts off the orange line after the the point to which there is no more data available. 

WM117_0-1754653818215.png

Currently I use this measure: 

Cumulative_Geschreven Uren = 
            CALCULATE(SUM('Urenregistratie'[Geschreven uren]),
            FILTER(ALLSELECTED( DateTable),
            DateTable[Date] <= MAX( DateTable[Date])))

 

ChatGPT recommened me this measure, but in this case the line cuts off in June, while there is data from the month July (see picture below). In this case i used the following DAX.

 

Cumulative_Geschreven Uren (Cutoff) = 
VAR CurrentDate =
    MAX(DateTable[Date])
VAR LastDateWithData =
    CALCULATE(
        MAX(DateTable[Date]),
        FILTER(
            ALLSELECTED(DateTable),
            CALCULATE(SUM('Urenregistratie'[Geschreven uren])) <> 0
        )
    )
RETURN
IF(
    CurrentDate <= LastDateWithData,
    CALCULATE(
        SUM('Urenregistratie'[Geschreven uren]),
        FILTER(
            ALLSELECTED(DateTable),
            DateTable[Date] <= CurrentDate
        )
    )
)

 

WM117_1-1754654188597.png

 

Any solution would be greatly appreciated! 

 

Willem

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

The code is nearly correct, I think that the problem is because you are showing the data at the month granularity. The value returned by MAX( DateTable[Date] ) will return the 31st July, whereas the LastDateWithData could be e.g. 15th July.

You can fix it by checking the current date against the end of the last month with data in it.

Cumulative_Geschreven Uren (Cutoff) =
VAR CurrentDate =
    MAX ( DateTable[Date] )
VAR LastDateWithData =
    EOMONTH (
        CALCULATE (
            MAX ( DateTable[Date] ),
            FILTER (
                ALLSELECTED ( DateTable ),
                CALCULATE ( SUM ( 'Urenregistratie'[Geschreven uren] ) ) <> 0
            )
        ),
        0
    )
RETURN
    IF (
        CurrentDate <= LastDateWithData,
        CALCULATE (
            SUM ( 'Urenregistratie'[Geschreven uren] ),
            FILTER ( ALLSELECTED ( DateTable ), DateTable[Date] <= CurrentDate )
        )
    )

View solution in original post

2 REPLIES 2
WM117
Frequent Visitor

Hi Johnt75,

 

Your edit worked! Thank you so much! I've accepted it as a solution. Good weekend to you!

johnt75
Super User
Super User

The code is nearly correct, I think that the problem is because you are showing the data at the month granularity. The value returned by MAX( DateTable[Date] ) will return the 31st July, whereas the LastDateWithData could be e.g. 15th July.

You can fix it by checking the current date against the end of the last month with data in it.

Cumulative_Geschreven Uren (Cutoff) =
VAR CurrentDate =
    MAX ( DateTable[Date] )
VAR LastDateWithData =
    EOMONTH (
        CALCULATE (
            MAX ( DateTable[Date] ),
            FILTER (
                ALLSELECTED ( DateTable ),
                CALCULATE ( SUM ( 'Urenregistratie'[Geschreven uren] ) ) <> 0
            )
        ),
        0
    )
RETURN
    IF (
        CurrentDate <= LastDateWithData,
        CALCULATE (
            SUM ( 'Urenregistratie'[Geschreven uren] ),
            FILTER ( ALLSELECTED ( DateTable ), DateTable[Date] <= CurrentDate )
        )
    )

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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.