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
naoyixue1
Post Patron
Post Patron

Weeks of coverage calculation based on the forward looing demands in Power BI

Hey all,

 

I got a problem to calculate the weeks of coveage based on the forward looking demands (see below example) 

naoyixue1_0-1674538168804.png

Item A: Weeks of coverage = 8/11 = 0.72

Item A: Because the first 5 weeks demands is 33. By the end of the 5th weeks, the leftover inventory is about 18 = 51-1-1-5-11-15. Given that, we only can fulfill 90% of the 6th week demands, which is 18 / 20 = 0.9. SO Item B 's weeks of coverage is about 5.9. 

 

Do you know what logic or how we can apply in BI to calculate that? Thanks!

6 REPLIES 6
naoyixue1
Post Patron
Post Patron

Hey all,

 

That's my thoughts.  (see below example)  I'm now stuck to transfer that way of calculation into dax. Do you have any ideas how in dax? Thanks!

 

Steps:

1: Add the running total column to highlight the cumulative demands

2: mark "1" if we can hit that day's running total demands (day 1 thru day 6)

3: for the day which we cannot cover the running total (day 7). I will use the leftover which i have at the end of day 6 ( 9 = 100 - 91). And then use 9 units divided by that day (day 7) demands.  9 / 110 = 0.08. In other words, we only can cover 0.08 days of day 7 demands. 

4: add those days of coverage together. So total will be 6.08 days coverage. 

naoyixue1_1-1674688821705.png

 

 

 

Anonymous
Not applicable

HI @naoyixue1,

I enter to the query editor to use the 'unpivot column' and 'replace value' function on your table to change its structure for following calculations.

2.PNG

Measure formula:

formula = 
VAR currItem =
    SELECTEDVALUE ( 'Table'[Item] )
VAR summary =
    SUMMARIZE (
        ALLSELECTED ( 'Table' ),
        [Item],
        [Inventory],
        [Days],
        "Rolling",
            CALCULATE (
                SUM ( 'Table'[Value] ),
                FILTER ( ALLSELECTED ( 'Table' ), [Days] <= MAX ( 'Table'[Days] ) ),
                VALUES ( 'Table'[Item] )
            )
    )
VAR days =
    MAX (
        MAXX (
            FILTER ( summary, [Item] = currItem && [Rolling] <= [Inventory] ),
            [Days]
        ),
        1
    )
RETURN
    IF (
        days = 1,
        CALCULATE (
            DIVIDE ( MAX ( 'Table'[Inventory] ), MAX ( 'Table'[Value] ) ),
            FILTER ( ALLSELECTED ( 'Table' ), [Days] = 1 ),
            VALUES ( 'Table'[Item] )
        ),
        VAR rolling =
            CALCULATE (
                SUM ( 'Table'[Value] ),
                FILTER ( ALLSELECTED ( 'Table' ), [Days] <= days ),
                VALUES ( 'Table'[Item] )
            )
        RETURN
            days
                + CALCULATE (
                    DIVIDE ( MAX ( 'Table'[Inventory] ) - rolling, MAX ( 'Table'[Value] ) ),
                    FILTER ( ALLSELECTED ( 'Table' ), [Days] = days + 1 ),
                    VALUES ( 'Table'[Item] )
                )
    )

1.PNGRegards,

Xiaoxin Sheng

@Anonymous Thanks Xiaoxin. Let me check that. Really appreicate that. Will let you know after test. 

naoyixue1
Post Patron
Post Patron

Hey all, sorry i just check to see whehter you all have some thoughts? I really don't find any similar problems here. Thanks a lot!

naoyixue1
Post Patron
Post Patron

Hey all,

I know that might be tough without the sample BI table, so I just attach that BI table. Would you take a look about that? That will be helpful even you just share your thoughts. Thanks!

naoyixue1
Post Patron
Post Patron

Does anyone have any thoughts about how? Thanks!

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!

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.

Top Solution Authors