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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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

Share with Power BI Enthusiasts: 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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.