Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Receivable Balance Measure

Hello -

Having trouble with arriving at the Receivable Balance calculation Measure. Goal is to provide the Balance of Customer as of a particular Historical date . 

I tried using the measure to calculate Invoice value - All Receipts, as of the sellected  date, but does not seem to be working. Not sure wht i am messing up. Please help. 

 

Invoice Table 

CustomerInvoiceInvoice DateValue
CUS1INV-L18/20/2023100
CUS1INV-L28/20/2023150
CUS1INV-19/1/2023500
CUS1INV-29/15/20231000
CUS1INV-39/25/20232000
CUS5INV-610/4/20231100

 

Receipts of all invoices and any advance payment 

CustomerInvoiceRcpt DateValue
CUS1INV-L19/5/2023-100
CUS1INV-19/1/2023-200
CUS1INV-19/29/2023-200
CUS1INV-29/30/2023-1000
CUS1INV-110/2/2023-50
CUS2ADV-19/20/2023-250

 

Created measure -  

Balance = CALCULATE(SUM(InvTable[Value]), FILTER(ALL(InvTable[Invoice Date]),InvTable[Invoice Date]<= MAX('Calendar'[Date]))) -
CALCULATE(SUM(RcptTable[Value]), FILTER(ALL(RcptTable[Rcpt Date]),RcptTable[Rcpt Date] <= MAX('Calendar'[Date])))
 
Current Month measure need to select the balnce for that month. ( all invoices happened in the month and less receipts in that month )
Expected results if selected date - 8/31/2023
CustomerBalanceCurrent Month 
CUS1250250

 

Expected results for selected date 9/30/2023 

 

CustomerBalanceCurrent Month 
CUS122502100
CUS2-250 

 

Pbix attached   https://drive.google.com/file/d/1k4aGruU1ObhUurwYHRocYP5QC0Tj2vfq/view?usp=sharing

  • Hi Anonymous ,

     

    You can simply your calculation but using the related calendar table instead of the facts table in your measure so for balance, that would be

    CALCULATE (
            SUM ( InvTable[Value] ) + SUM ( RcptTable[Value] ),
            FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= MAX ( 'Calendar'[Date] ) )
        )

    What I don't get is your current month number for CUS1. Per data, that should be 2000 and not 2100 (3500-1500).

    Please see attached pbix for details.

     

     

4 Replies

  • 123abc's avatar
    123abc
    Community Champion

    It looks like you are trying to create a measure to calculate the receivable balance for a specific historical date. The measure you provided seems close, but it might need a few adjustments. Here's an updated version of your measure:

     

    Receivable Balance =
    CALCULATE(
    SUM(Invoice[Value]),
    FILTER(
    ALL(Invoice),
    Invoice[Invoice Date] <= MAX('Calendar'[Date])
    )
    ) -
    CALCULATE(
    SUM(Receipts[Value]),
    FILTER(
    ALL(Receipts),
    Receipts[Rcpt Date] <= MAX('Calendar'[Date])
    )
    )

     

    Here, I've replaced InvTable and RcptTable with Invoice and Receipts to match the table names you provided. Also, I removed the unnecessary SUMX function and simplified the formula.

    Make sure to replace Invoice and Receipts with the actual names of your tables.

    Now, you can use this measure in your visualizations. If you want to get the receivable balance for a specific date, use the date as a filter context in your report or use it in a CALCULATE statement.

    For the current month measure, you can use a similar approach:

     

    Current Month Receivable Balance =
    CALCULATE(
    [Receivable Balance],
    FILTER(
    ALL('Calendar'),
    'Calendar'[Date] >= STARTOFMONTH(MAX('Calendar'[Date])) &&
    'Calendar'[Date] <= MAX('Calendar'[Date])
    )
    )

     

    This measure calculates the receivable balance for the current month based on the selected date.

    Now, when you select a specific date, you should get the expected results for the receivable balance and the current month receivable balance in your report.

     
     
     
     

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

     

    In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks 123abc for the help. 

      I had trouble with receivable balance measure with the above approach. 

       

       

  • Hi Anonymous ,

     

    You can simply your calculation but using the related calendar table instead of the facts table in your measure so for balance, that would be

    CALCULATE (
            SUM ( InvTable[Value] ) + SUM ( RcptTable[Value] ),
            FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= MAX ( 'Calendar'[Date] ) )
        )

    What I don't get is your current month number for CUS1. Per data, that should be 2000 and not 2100 (3500-1500).

    Please see attached pbix for details.

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

       

      Thanks danextian .You are right. It is 2000. Good solution.