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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Calculate Sum of weekly value only if previous week was negative

I am trying to do a running sum af resource availability.  But if a resource is over-used the previous week, I would like to subtract it from the current week.  If it is under-used I do not want it to carry forward.  For instance:

 

Capacity1414141414
Orders1216131210
Available2-2-114
3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , do you same week or Date to do that.

You can refer these WOW blog/video, if they can help

 

https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
https://www.youtube.com/watch?v=pnAesWxYgJ8

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
AllisonKennedy
Super User
Super User

@Anonymous  What does your raw data look like please? 

 

You can do IF([Available]<0, [Available]+[Current], [Current])

 

type of logic, but we need to know what your raw data looks like to be able to detail exactly how. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

My data includes:

Column: Truck Capacity

MEASURE: Open Orders = (SUM('Table1'[Converted Volume])/31) +0
MEASURE: Available Calculation = CALCULATE(SUM(Table2[Truck Capacity])-[Open Orders])
 
I am currently using this measure for the running calculation: 
Available Running Total = IF(
CALCULATE([Available Calculation]<0, DATEDIFF(Table2[Shipment Date], TODAY(), WEEK) = 1),
CALCULATE(
    [Available Calculation],
    FILTER(
        ALLSELECTED('Table2'[Shipment Date]),
        ISONORAFTER('Table2'[Shipment Date], MAX('Table2'[Shipment Date]), DESC)
    )
),[Available Calculation])
But the problem is, if this week is positive and last week was negative, it does not carry the negative value forward.  So I need to look if the previous Available Running Total is negative, then I need to carry it forward.  But I feel like that creates a circular equation.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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