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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Frequent Visitor

Dynamic AR Aging Not working on Customer Level



I am trying to build a series of measures for a report that will dynamically calculate the AR aging by buckets (current, <15 days overdue, 16-30 days overdue, 31-90 days overdue, 90+ overdue) based on a slicer. I have the following set up:


1) Date reference table

2) Transaction table with the following key fields: Transaction Date (of sale), Due Date, and Closed Date. If something is not yet paid, and thus active AR, the closed date has a future date. That is the way the system is set up. 

3) Measure #1 

Invoice Aging =
VAR CurrentDate = calculate(max('Reference Dates'[Date]),
USERELATIONSHIP('Reference Dates'[Date],'Sales and Collections'[CLOSED]))
VAR AgingDifference = calculate(datediff(max('Sales and Collections'[DUEDATE]),CurrentDate,DAY),
ALL('Reference Dates'[Date]),
'Sales and Collections'[CLOSED]>CurrentDate,
'Sales and Collections'[TRANSDATE]<=CurrentDate)
VAR AgingBucket = if(isblank(AgingDifference),blank(),


This measure seems to be working on an invoice by invoice basis, but it doesn't work when summed up. See below for an exmaple when the slicer is set on October 16th: 



However, when I try to do a summary table (I want to see the sum of all invoices by each bucket, for example $60k are current, $8k are <15, etc.) but it all buckets it into current. Can someone help fix this measure? 





Community Support
Community Support

Hi @Controller123 ,


According to your statement, I know [Invoice Aging] should be a measure. Measure will only show aggregate value as your screenshot. So this measure will work by invoice basis and will only show one bucket "Current" when you remove invoice column.

Currently you want to show the sum of all invoices by each bucket, I suggest you to add an unrelated bucket table with all aging bucket into your data model.

Then try this measure.

New_Sales =
        'Sales and Collections',
        'Sales and Collections'[INVOICE],
        'Sales and Collections'[Sales],
        "Invoice Aging",
            VAR CurrentDate =
                CALCULATE (
                    MAX ( 'Reference Dates'[Date] ),
                    USERELATIONSHIP ( 'Reference Dates'[Date], 'Sales and Collections'[CLOSED] )
            VAR AgingDifference =
                CALCULATE (
                    DATEDIFF ( MAX ( 'Sales and Collections'[DUEDATE] ), CurrentDate, DAY ),
                    ALL ( 'Reference Dates'[Date] ),
                    'Sales and Collections'[CLOSED] > CurrentDate,
                    'Sales and Collections'[TRANSDATE] <= CurrentDate
            VAR AgingBucket =
                IF (
                    ISBLANK ( AgingDifference ),
                    BLANK (),
                    IF (
                        AgingDifference <= 0,
                        IF (
                            AgingDifference <= 15,
                            IF (
                                AgingDifference <= 30,
                                IF (
                                    AgingDifference <= 90,
                                    IF ( AgingDifference > 90, ">90", BLANK () )
    SUMX (
        FILTER ( _SUMMARIZRE, [Invoice Aging] = MAX ( 'Invoice Aging'[Invoice Aging] ) ),


Best Regards,
Rico Zhou


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

Hey @v-rzhou-msft . Thanks for the proposed solution. I shifted this Invoice Aging metric to a table named Invoice Aging. The table looks like this: 



When I pasted your formula into a new measure in this table, i get the following errors:







How can i fix these errors? 


For reference, here is the sales measure that is causing the issue, which sums up the amount for every transaction type but 15 (which is payments) 





@v-rzhou-msft Do you have an update on my question? 

Helpful resources

Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.