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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Beezer70
Frequent Visitor

Use value of measure from previous row in the same measure

I have a measure called 'End Avail Inv (W)' that should either return our actual ending inventory for each historical week, or project the ending inventory for future weeks based on Prior Week Ending Inventory - Demand + Supply.  This measure works for history and through the first future week, but then only returns the difference between our demand and supply after that.  

I need the value to be carried forward week over week.
The 'Beg Avail Inv (W)' measure should be equal to the previous weeks 'End Avail Inv (W)' value, but in the second future week, it is also returning just the difference between demand and supply.

 

Beezer70_1-1720707134348.png

The greyed out columns are just for reference and are not part of the End Avail Inv calculation

 

End Avail Inv (W) =
--True Inventory for Week Ending Dates in the past and current weeks
--Projected Inventory for future weeks based on prior week’s Ending Inventory
--[Demand (True) (W)] is a measure returning the greater of 'Cust Order (Req Dt)' and 'Demand - IBP (W)'
--[Supply] is a measure retruning the summation of products both produced and purchased
--[End Avail Inv (HANA)] is the week ending inventory or current inventory. Furture weeks show up blank.
VAR _PriorEndInv =  
 CALCULATE([End Avail Inv (HANA)],
            WINDOW(-1, REL, -1, REL,
                ALLSELECTED(
                'Calendar (HANA)'[FISCAL_WEEK_END_DT],
                'Calendar (HANA)'[Wk Act/Fcst]
            )
        )
    )
RETURN
IF(ISBLANK([End Avail Inv (HANA)]), _PriorEndInv - [Demand (True) (W)] + [Supply], [End Avail Inv (HANA)])
2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@Beezer70 This smells a bit like recursion which DAX hates. However in some cases you can get around it. If you can post sample data that would speed things along. 

 

Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

This is definately a recursion issue.  It is easy to produce the result I want in Excel

The final output should look like this:

Beezer70_0-1720717210505.png

All the values in the visualization are measures coming from different sources, but matched on key fields

 

[End Avail Inv (W)] = [Beg Avail Inv(W)] - [Demand (True) (W)] + [Supply]
[Beg Avail Inv (W)] = [End Avail Inv (W)] of the previous week

[Demand (True) (W)]  = the greater of [Customer Orders received by Request Date] and [Forecasted Demand]

[Supply] = [Planned Production for the week] + [Goods Purchased- being received in the week]

Sample Data:

FW End DtWk Act/Fcst Beg Avail Inv (W)  Demand (True) (W)  Supply  End Avail Inv (W) 
6/29/2024Act              48,124,924                     3,629,903         1,116,043              45,832,998
7/6/2024Act              45,832,998                     3,058,383         1,173,134              44,805,817
7/13/2024CW              44,805,817                     3,189,715         2,562,888              44,773,892
7/20/2024Fcst              44,773,892                     2,989,246         5,806,530              47,591,177
7/27/2024Fcst              47,591,177                     2,989,566         2,053,462              46,655,073
8/3/2024Fcst              46,655,073                     2,989,510         2,760,012              46,425,575
8/10/2024Fcst              46,425,575                     2,975,109         2,359,286              45,809,752
8/17/2024Fcst              45,809,752                     2,974,497         2,646,340              45,481,595
8/24/2024Fcst              45,481,595                     2,974,092         2,281,750              44,789,253
8/31/2024Fcst              44,789,253                     2,973,774         3,107,209              44,922,688

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors