Forum Discussion

PowerBITestingG's avatar
PowerBITestingG
Resolver I
3 years ago

Running total and max date

I have a simple table with product week number and a running total measure:

 

Running Total = 
var maxdate = MAX(week)
return
CALCULATE(SUM(quantity),week<=maxdate)

 

 

Product141516
Macbook204060
PC1020 

 

My problem is that I am not getting the running total for product PC week 16. I want it to display 20

 

There is no data for that week in the table which is just Product/Week/Quantity.

 

I tried linking it to a time table, but I still get the same issue

 

 

1 Reply

  • Hello PowerBITestingG,

     

    Could you please try this:

    Running Total = 
    VAR MaxDate = MAX(week)
    RETURN
    CALCULATE(
        SUM(quantity),
        FILTER(
            ALL(week),
            week <= MaxDate
                && (ISBLANK(SUM(quantity)) || week > Max(week[week]))
        )
    )

     

    Let me know if you might need further assistance.