Skip to main content
cancel
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

Reply
Controller123
Frequent Visitor

Dynamic AR Aging Not working on Customer Level

Hello,

 

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(),
if(
AgingDifference<=0,"Current",
if(AgingDifference<=15,"<=15",
if(AgingDifference<=30,"16-30",
if(AgingDifference<=90,"31-90",
if(AgingDifference>90,">90",blank()))))))
RETURN
AgingBucket

 

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: 

Controller123_0-1678200973709.png

 

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? 

 

Controller123_1-1678201083988.png

 

 

3 REPLIES 3
v-rzhou-msft
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 =
VAR _SUMMARIZRE =
    SUMMARIZE (
        '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,
                        "Current",
                        IF (
                            AgingDifference <= 15,
                            "<=15",
                            IF (
                                AgingDifference <= 30,
                                "16-30",
                                IF (
                                    AgingDifference <= 90,
                                    "31-90",
                                    IF ( AgingDifference > 90, ">90", BLANK () )
                                )
                            )
                        )
                    )
                )
            RETURN
                AgingBucket
    )
RETURN
    SUMX (
        FILTER ( _SUMMARIZRE, [Invoice Aging] = MAX ( 'Invoice Aging'[Invoice Aging] ) ),
        [Sales]
    )

 

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: 

Controller123_0-1678389916247.png

 

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

 

1) 

Controller123_1-1678389975562.png

2) 

Controller123_2-1678390011880.png

 

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) 

Controller123_3-1678390064921.png

 

 

 

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

Helpful resources

Announcements
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.