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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mike999
Frequent Visitor

Backward calculate backlog

I have the table below in Power BI ("table1") and I need to calculate the values in red working backwards.

calculation for the "known" backlog value for tiday. xOpenCountToday = CALCULATE(count(_Active[ID]),ALL(table1[Date]),'table1'[Date]=TODAY())


I've tried all the various examples on this community board, but just can't get it to work. What is the DAX statement that I should be using (I'm new to dax)? If I was using SQL that I would use lead and lag window functions.

 

Thank you in advance for your time and any assistance you can provide.

 

DateNameIncomingOutgoingBacklog  
10-AprUserA101233  
11-AprUserA4433  
12-AprUserA6237  
13-AprUserA8441  
14-AprUserA3242  
15-AprUserA1439 value=backlog from next day (39) +Outgoing for next day (3) - Incoming for next day (3) = 39
16-AprUserA3339 value=backlog from next day (40) +Outgoing for next day (0) - Incoming for next day (1) = 39
17-AprUserA1040 Value (40) in this is known (see above)
10-AprUserB221257  
11-AprUserB5755  
12-AprUserB2651  
13-AprUserB6552  
14-AprUserB8357  
15-AprUserB2257 value=backlog from next day (59) +Outgoing for next day (1) - Incoming for next day (3) = 57
16-AprUserB3159 value=backlog from next day (60) +Outgoing for next day (0) - Incoming for next day (1) = 59
17-AprUserB1060 Value (60) in this is known (see above)

 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @mike999 ,

You can create a measure as belwo to get it, please find the details in the attachment.

Backlog = 
VAR _seldate =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _selname =
    SELECTEDVALUE ( 'Table'[Name] )
VAR _culincome =
    CALCULATE (
        SUM ( 'Table'[Incoming] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Name] = _selname
                && 'Table'[Date] > _seldate
        )
    )
VAR _culoutcome =
    CALCULATE (
        SUM ( 'Table'[Outgoing] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Name] = _selname
                && 'Table'[Date] > _seldate
        )
    )
RETURN
    [xOpenCountToday] + _culoutcome - _culincome

vyiruanmsft_0-1681884180470.png

Best Regards

Community Support Team _ Rena
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

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @mike999 ,

You can create a measure as belwo to get it, please find the details in the attachment.

Backlog = 
VAR _seldate =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _selname =
    SELECTEDVALUE ( 'Table'[Name] )
VAR _culincome =
    CALCULATE (
        SUM ( 'Table'[Incoming] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Name] = _selname
                && 'Table'[Date] > _seldate
        )
    )
VAR _culoutcome =
    CALCULATE (
        SUM ( 'Table'[Outgoing] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Name] = _selname
                && 'Table'[Date] > _seldate
        )
    )
RETURN
    [xOpenCountToday] + _culoutcome - _culincome

vyiruanmsft_0-1681884180470.png

Best Regards

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

Thank you Rena. That appears to be working - Thank you so much 👍

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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