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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
LotteLaugesen
Helper V
Helper V

Highest outstanding per customer in a period

Hi

 

I need to find the highest outstanding per customer in a given period.

In my table I have invoices and payments and of course date, customer number and amount.

 

Do you have any suggestions?

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

If you create a measure like

Outstanding Amount =
VAR maxDate =
    MAX ( 'Date'[Date] )
VAR invoicedAmount =
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        REMOVEFILTERS ( 'Date' ),
        ALLEXCEPT ( 'Table', 'Table'[Customer No] ),
        'Table'[Date] <= maxDate,
        'Table'[Type] = "Invoice"
    )
VAR paidAmount =
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        REMOVEFILTERS ( 'Date' ),
        ALLEXCEPT ( 'Table', 'Table'[Customer No] ),
        'Table'[Date] <= maxDate,
        'Table'[Type] = "Payment"
    )
RETURN
    invoicedAmount - paidAmount

then your max outstanding amount would be

Max Outstanding = MAXX( VALUES('Date'[Date]), [Outstanding Amount])

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

If you create a measure like

Outstanding Amount =
VAR maxDate =
    MAX ( 'Date'[Date] )
VAR invoicedAmount =
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        REMOVEFILTERS ( 'Date' ),
        ALLEXCEPT ( 'Table', 'Table'[Customer No] ),
        'Table'[Date] <= maxDate,
        'Table'[Type] = "Invoice"
    )
VAR paidAmount =
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        REMOVEFILTERS ( 'Date' ),
        ALLEXCEPT ( 'Table', 'Table'[Customer No] ),
        'Table'[Date] <= maxDate,
        'Table'[Type] = "Payment"
    )
RETURN
    invoicedAmount - paidAmount

then your max outstanding amount would be

Max Outstanding = MAXX( VALUES('Date'[Date]), [Outstanding Amount])

Thank you @johnt75 - it works perfect 👍

LotteLaugesen
Helper V
Helper V

Example 😉

LotteLaugesen_1-1657275237403.png

 

So if the filtered period is 1/3/2022 - 31/3/2022 it should show row 4 and 9

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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