Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

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)

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

    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

    Best Regards

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    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

    Best Regards

    • Anonymous's avatar
      Anonymous
      Not applicable

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