cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Need help on Cumulative Sum to Stop at last 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 am specifically looking at the green line in the chart on the left and the red/green lines on the right

Thank you

Baseline Weekly =
CALCULATE(
SUM(fact_Progress[Value]),
FILTER(ALLSELECTED(dim_Date),dim_Date[CurWeekOffset] <= MAX(dim_Date[CurWeekOffset])),
FILTER(ALLSELECTED(fact_Progress),fact_Progress[Type]="Target"))

Capture.JPG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I got it. here is what I did (note table names are slightly different from original). I am guessing it is because my primary table had additional dates beyond the max target date, so I included a filter on the original max date calculation for "target" only. Thank you for your help

 

 

Original Baseline Weekly2 = 
VAR MaxDate = CALCULATE(MAX(fact_ManhourProgress[Date]),FILTER(fact_ManhourProgress,fact_ManhourProgress[Type]="Target"))
RETURN
    CALCULATE (
        SUM ( fact_ManhourProgress[Value] ),
        FILTER (
            ALLSELECTED ( dim_Date ),
            dim_Date[Date] <= MaxDate
        ),
        FILTER ( ALLSELECTED ( fact_ManhourProgress ), fact_ManhourProgress[Type] = "Target" )
    )

 

View solution in original post

6 REPLIES 6
MFelix
Super User
Super User

Hi  @Anonymous ,

 

Try to add the following code:

 

Baseline Weekly =
IF (
    MAX ( dim_Date[CurWeekOffset] )
        >= CALCULATE ( MAX ( fact_Progress[Date] ), ALL ( fact_Progress[Date] ) ),
    BLANK (),
    CALCULATE (
        SUM ( fact_Progress[Value] ),
        FILTER (
            ALLSELECTED ( dim_Date ),
            dim_Date[CurWeekOffset] <= MAX ( dim_Date[CurWeekOffset] )
        ),
        FILTER ( ALLSELECTED ( fact_Progress ), fact_Progress[Type] = "Target" )
    )
)

Replace the fact_Progress[Date] by the column date of your fact_progress.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

I get the same result with that formula as my previous. Any other solutions?

Hi,

Can you share a sample file please.

Regards,
MFelix

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

I can't share a sample file. The current week offset of my dim_date table is a numeric number based on the # of days from present (yesterday is -1, today is 0, tomorrow is +1). Could this be the problem with your formula?

Hi @Anonymous ,

 

Without any other information about your model is difficult to help you.

 

Can you share the way your model is setup and a sample of the information so I can make some tests?

 

If you don't want to share the file because it's sensitive information you can do it through private message or make a mockup file with the structure and sample data.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

I got it. here is what I did (note table names are slightly different from original). I am guessing it is because my primary table had additional dates beyond the max target date, so I included a filter on the original max date calculation for "target" only. Thank you for your help

 

 

Original Baseline Weekly2 = 
VAR MaxDate = CALCULATE(MAX(fact_ManhourProgress[Date]),FILTER(fact_ManhourProgress,fact_ManhourProgress[Type]="Target"))
RETURN
    CALCULATE (
        SUM ( fact_ManhourProgress[Value] ),
        FILTER (
            ALLSELECTED ( dim_Date ),
            dim_Date[Date] <= MaxDate
        ),
        FILTER ( ALLSELECTED ( fact_ManhourProgress ), fact_ManhourProgress[Type] = "Target" )
    )

 

Helpful resources

Announcements
collabdays lisbon

CollabDays Lisbon - 26 November 2022

Sessions include practical, hands-on experience that will help you take the next step in your career and know-how.

Difinity Conference

Difinity Conference 2022

Difinity is the largest Microsoft Data, AI, Power BI, Power Platform and Business Applications Conference in New Zealand.

European Share Point Conference

European Share Point Conference

This conference returns live and in-person in Copenhagen this 28 November-01 December with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.