web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Customer Ageing Report SQL query.

(4) ShareShare
ReportReport
Posted on by 15
Hi, I am trying to create the customer ageing report sql query logic but not getting the correct balance when going for the back dates instead of current date.
Below is the SQL query for the raw data and the buckets I have created in Power BI for the Due Date.
 
SELECT
    custtrans.dataareaid AS Company,
    custtrans.accountnum AS customerNo,
    custtable.custgroup AS customerPostingGroup,
    custtrans.currencycode AS currencyCode,
    custtransopen.amountmst AS Balance,
    --CASE
    -- WHEN `` = 'Sales order' THEN custtrans.amountmst ELSE 0
   -- END AS salesLCY,
    custtrans.invoice AS documentNo,
    custtrans.duedate AS DueDate,
    custtrans.transtype_$label AS documentType,
    custtrans.transdate AS postingDate,
    custtrans.voucher AS customerLedgerEntryNo,
    dirpartytable.name AS CustomerName
FROM custtrans
LEFT JOIN custtransopen ON
    custtrans.accountnum = custtransopen.accountnum
    AND custtrans.dataareaid = custtransopen.dataareaid
    AND custtrans.recid = custtransopen.refrecid
LEFT JOIN custtable ON
    custtrans.accountnum = custtable.accountnum AND
    custtrans.dataareaid = custtable.dataareaid
LEFT JOIN dirpartytable ON
    custtable.party = dirpartytable.recid
Categories:
I have the same question (0)
  • Verified answer
    André Arnaud de Calavon Profile Picture
    303,780 Super User 2026 Season 1 on at
    Hi,

    Somehow your question was created in the old group for Dynamics AX. I have moved it to the actual Dynamics AX forum. Can you confirm your version of Dynamics?

    What exactly do you mean by back dates? Do you want to run the report for e.g. end of June? In your query, I don't see a date range. If the date range is set in your Power BI report, then you need to gather other transactional data. 
     
    Then you need to have the amount from the CustTrans record as the CustTransOpen table only has information about current open amounts. 
    The historical amounts can be calculated if you take details from the CustSettlement table into account of your Power BI report. Then you can check on what date the transaction was settled and which payments are marked against what invoices.
  • Sohaib Cheema Profile Picture
    49,677 Super User 2026 Season 1 on at
    Andre's suggestion is good. 
    I also see that you do not have any bucket's logic (such as 1-30 days, 30-60 days, 60-90 days and so on). Looks like you want to get the balance due as of today (that would not be aging report but balance report).  For Aging report, it needs a direction (forward, backward) and date criteria. 
     
  • KP-31070522-0 Profile Picture
    15 on at
     
    Here back dates means user defined dates it can be June, May or others. And the date range is set in the Power BI. And I am getting all the transactional data in Power BI.
     
    So do I need to consider the CustSettlement transactions also?
  • André Arnaud de Calavon Profile Picture
    303,780 Super User 2026 Season 1 on at
    Hi,
     
    Yes, for reports where you need to have an overview of a situation in the past, you will need the CustSettlement table.
  • Suggested answer
    Navneeth Nagrajan Profile Picture
    2,550 Super User 2026 Season 1 on at
    Hi KP-31070522-0,
     
    As Andre mentioned, go ahead and use the Customer settlement table. In addition to this, the field to refer to in customer transactions and customer settlements will be the ReportingCurrencyAmount in PowerBI. Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 676

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 462 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 335 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans