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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Stop cumulative line when there is no value

Hi there, my cumulative sum is extending to further dates where there are blank values. I need it to stop when there is no more data. 

I attached my example PBI file here : PBI share 

it's a cumulative line graph shoing forecast, actual and plan by week.

 

hope this is clear question for you. 

any ideas would be much appreciated.

 

ffff.PNG

1 ACCEPTED SOLUTION

@Anonymous 

That is because the MAX Sheet2[IRN] is August 21 but the MAX of week 2020-34 is August 22.  If we adjust it like so it will show up.

 

CSU SP_IRN = 
VAR _End = CALCULATE ( MAX ( Sheet2[IRN] ), ALL ( 'Date' ) )
RETURN
    IF (
        _End < MIN ( 'Date'[Date] ),
        BLANK (),
CALCULATE(
	COUNTA('Sheet2'[IRN]), USERELATIONSHIP(Sheet2[IRN],'Date'[Date]),
	FILTER(
		ALLSELECTED('Date'[Date]),
		('Date'[Date] <= MAX('Date'[Date])))))

 

Basically we are looking if the _End is before the start of the week rather than the end of the week.
2020-08-19_19-16-50.png

View solution in original post

8 REPLIES 8
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
jdbuchanan71
Super User
Super User

@Anonymous 

You can add a check to each measure for the MAX date, something like so:

CSU SP_ROS = 
VAR _End = CALCULATE ( MAX ( Sheet2[ROS] ), ALL ( 'Date' ) )
RETURN
    IF (
        MAX ( 'Date'[Date] ) > _End,
        BLANK (),
        CALCULATE (
            SUM ( 'Sheet2'[ROS ITEM] ),
            USERELATIONSHIP ( Sheet2[ROS], 'Date'[Date] ),
            FILTER (
                ALLSELECTED ( 'Date'[Date] ),
                ( 'Date'[Date] <= MAX ( 'Date'[Date] ) )
            )
        )
    )

jdbuchanan71_0-1597883625018.png

 

Anonymous
Not applicable

@jdbuchanan71  Thanks for your reply.

This code works what i want to show but there is 1 out of 4 lines in the graph stops somehow 1 week early.

the IRN is supposed to stop W34 with value 202 but it stops W33. do you know why this code didn't count W34 for IRN?

@Anonymous 

That is because the MAX Sheet2[IRN] is August 21 but the MAX of week 2020-34 is August 22.  If we adjust it like so it will show up.

 

CSU SP_IRN = 
VAR _End = CALCULATE ( MAX ( Sheet2[IRN] ), ALL ( 'Date' ) )
RETURN
    IF (
        _End < MIN ( 'Date'[Date] ),
        BLANK (),
CALCULATE(
	COUNTA('Sheet2'[IRN]), USERELATIONSHIP(Sheet2[IRN],'Date'[Date]),
	FILTER(
		ALLSELECTED('Date'[Date]),
		('Date'[Date] <= MAX('Date'[Date])))))

 

Basically we are looking if the _End is before the start of the week rather than the end of the week.
2020-08-19_19-16-50.png

Greg_Deckler
Community Champion
Community Champion

@Anonymous - Didn't my code work for this? (attached)

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

HI @Greg_Deckler  

 

I have 4 lines in the graph. 1 line value doesn't appear properly.

The orange line is supposed to stop in week 34 with cumul vaule 202 but when i used your code it stops week 33 and the final vaule is 62, somehow the code didn't count w34 values and stop w33

 

Do you know why?

See the attached file -> PBI LINK 

 

fs.PNG

 

@Anonymous - It does not stop, it just happens to be very close to another color's value for most of the graph. See attached PBIX file updated where I move that measure to a column so that you can see it continues. I don't see the code that stops it that I wrote in the PBIX file.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler 

I checked as well after removing other lines. It stops W33 even though it has value till W34.

Can you please link the file again for me? i got error message and can't open it in my desktop.

errormase.PNG

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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
Top Kudoed Authors