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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Julio-YYC
Helper II
Helper II

Running Total Formula - Stop calculation at the latest data available

Hi there,

I have a measure cauculating my running total for hours spent:

 

Running Total Actual hr =
CALCULATE(
    SUM('4. Actual Manpower Forecast'[Actual hr]),
    FILTER(
        ALLSELECTED('Report/Week/Discipline'[Week Date]),
        ISONORAFTER('Report/Week/Discipline'[Week Date], MAX('Report/Week/Discipline'[Week Date]), DESC)
    )
)
 
However, I'd like to stop my calculation on Jan29th... as this is the latestdate with actuals hours. From Feb 05th onwards, I'd like to see blank values..

JulioYYC_1-1675374527506.png

any idea? 

 

thansk! 

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Julio-YYC 

 

You can try the following methods.

Measure:

Running = 
CALCULATE ( SUM ( 'Table'[Actual hr] ),
    FILTER ( ALL ( 'Table' ), [Week Date] <= SELECTEDVALUE ( 'Table'[Week Date] ) )
)
Result = 
 Var _maxtotal=MAXX(ALL('Table'),[Running])
 Var _lastdate=CALCULATE(MIN('Table'[Week Date]),FILTER(ALL('Table'),[Running]=_maxtotal))
 Return
 IF(SELECTEDVALUE('Table'[Week Date])>_lastdate,BLANK(),[Running])

vzhangti_0-1675390654027.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

View solution in original post

6 REPLIES 6
v-zhangti
Community Support
Community Support

Hi, @Julio-YYC 

 

You can try the following methods.

Measure:

Running = 
CALCULATE ( SUM ( 'Table'[Actual hr] ),
    FILTER ( ALL ( 'Table' ), [Week Date] <= SELECTEDVALUE ( 'Table'[Week Date] ) )
)
Result = 
 Var _maxtotal=MAXX(ALL('Table'),[Running])
 Var _lastdate=CALCULATE(MIN('Table'[Week Date]),FILTER(ALL('Table'),[Running]=_maxtotal))
 Return
 IF(SELECTEDVALUE('Table'[Week Date])>_lastdate,BLANK(),[Running])

vzhangti_0-1675390654027.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

That worked perfect! Thanks v-zhangti ! 

That worked perfect! Thanks v-zhangti !

AndreGiovannini
Frequent Visitor

Hi Julio,
 
I believe you could you could use a DATESBETWEEN as a filter, using its in date as date table and max date as today.

CALCULATE(
    SUM('4. Actual Manpower Forecast'[Actual hr]),
    FILTER(
        ALLSELECTED('Report/Week/Discipline'[Week Date]),
        ISONORAFTER('Report/Week/Discipline'[Week Date]MAX('Report/Week/Discipline'[Week Date]), DESC),
        DATESBETWEEN( 'date table and column', MIN ('date table and column'), today())
    )
 

Hi Andre, when I use your measure, I lost the cummulative calculation...weird (look at the last column): 

 

JulioYYC_0-1675378974190.png

Test Measure =
CALCULATE(
    SUM('4. Actual Manpower Forecast'[Actual hr]),
    FILTER(
        ALLSELECTED('Report/Week/Discipline'[Week Date]),
        ISONORAFTER('Report/Week/Discipline'[Week Date], MAX('Report/Week/Discipline'[Week Date]), DESC)
       
    ), DATESBETWEEN('Report/Week/Discipline'[Week Date],MIN('Report/Week/Discipline'[Week Date]), TODAY())
)

Hi,

Share the download link of the PBI file.


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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.