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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
rs1249
Helper I
Helper I

How to show a list of invoices a payment being allocated to in Power BI

Hi everyone, we are using s system called dynamics business central,

I need to run a report to show a list of invoices a payment is allocated to in power bi report, but just couldn’t figure out how our system manage to do it, and replicate that logic in power bi.

So I have two tables  "Cust_ledgerEntries" and "Detailed_Cust_Ledg_Entries", the relatetionship between the two tables is: "Cust_ledgerEntries"[Entr_No]--1:Many-->"Detailed_Cust_Ledg_Entries"[Cust_Ledger_Entry_No]

I can see in "Detailed_Cust_Ledg_Entries", When a invoice or payment posted, it creates an entry for each and set the entry type as "Initial Entry", each has "Detailed_Cust_Ledg_Entries"[Cust_Ledger_Entry_No] same as the "Cust_ledgerEntries"[Entr_No]. Something like this 

Invoice1 -200 1254

Invoice2 -100 1263

Invoice3 -200 1374

Payment 500 1568

 

when a payment is applied to an invoice or credit note, what system did was create two or more entries, with entry type sets as "Application" and their amounts offsets each other, Then cross assigns the [Cust_Ledger_Entry_No]

something Like below,

11 Payment -500 1568

16 Payment 200 1254

20 Payment 100 1263

31 Payment 200 1374

so that total balance remains the same. if I run power bi report  based on "Cust_ledgerEntries"[Entr_No], it does show all the payments and invoices been allcoated, but if I want to showa list of invoices being allocated to, there is no obvious link to do that?

 

I have looking at datasets for a week now, found no links to enable me to group the application entries together , but somehow our system can find way to do it, which drives me nuts. Can someone help me to see how should I use dax to do this?

 

Ideally, I would like the table to show something like this:

Document TypeDocument No.Posting DateDocument TypeDocument No.DescriptionAmountEntry No.
PaymentBANK-000092801/07/2018InvoiceINV-0001092Invoice INV-0001092168021541
PaymentBANK-000092801/07/2018InvoiceINV-0001106Invoice INV-000110684.8621590
PaymentBANK-000092801/08/2018InvoiceINV-0001267Invoice INV-0001267168023956
PaymentBANK-000092801/09/2018InvoiceINV-0001415Invoice INV-0001415168025472
PaymentBANK-000092801/09/2018InvoiceINV-0001416Invoice INV-00014167225475

 

The "Detailed_Cust_Ledg_Entries" table is like below:

Entry_NoPosting_DateEntry_TypeDocument_TypeDocument_NoCustomer_NoAmountDebit_AmountCredit_AmountInitial_Entry_Due_DateSource_CodeUnappliedUnapplied_by_Entry_NoCust_Ledger_Entry_No
420701/07/2018Initial EntryInvoiceINV-0001092C000005016801680001-Jul-18SALESFALSE021541
422101/07/2018Initial EntryInvoiceINV-0001106C000005084.8684.86001-Jul-18SALESFALSE021590
477101/08/2018Initial EntryInvoiceINV-0001267C000005016801680001-Aug-18SALESFALSE023956
532901/09/2018Initial EntryInvoiceINV-0001415C000005016801680001-Sep-18SALESFALSE025472
533001/09/2018Initial EntryInvoiceINV-0001416C00000507272001-Sep-18SALESFALSE025475
594530/09/2018Initial EntryInvoiceINV-0001536C000005050405040030-Sep-18SALESFALSE027381
594630/09/2018Initial EntryInvoiceINV-0001537C00000501512015120030-Sep-18SALESFALSE027398
733621/11/2018Initial EntryPaymentBANK-0000928C0000050-3024003024021-Nov-18PAYMENTJNLFALSE032306
878121/11/2018ApplicationPaymentBANK-0000928C0000050-16800168001-Jul-18SALESAPPLFALSE021541
878221/11/2018ApplicationPaymentBANK-0000928C000005025356.8625356.86021-Nov-18SALESAPPLFALSE032306
878321/11/2018ApplicationPaymentBANK-0000928C0000050-84.86084.8601-Jul-18SALESAPPLFALSE021590
878421/11/2018ApplicationPaymentBANK-0000928C0000050-16800168001-Aug-18SALESAPPLFALSE023956
878521/11/2018ApplicationPaymentBANK-0000928C0000050-16800168001-Sep-18SALESAPPLFALSE025472
878621/11/2018ApplicationPaymentBANK-0000928C0000050-7207201-Sep-18SALESAPPLFALSE025475
878721/11/2018ApplicationPaymentBANK-0000928C0000050-50400504030-Sep-18SALESAPPLFALSE027381
878821/11/2018ApplicationPaymentBANK-0000928C0000050-1512001512030-Sep-18SALESAPPLFALSE027398
1371301/06/2019ApplicationPaymentBANK-0000928C0000050381.3381.3021-Nov-18SALESAPPLTRUE1677332306
1539701/10/2019Initial EntryInvoiceINV-0003860C00000503636004-Oct-19SALESFALSE077851
1600326/10/2019Initial EntryInvoiceINV-0004012C0000050384384028-Oct-19SALESFALSE079816
1677301/06/2019ApplicationPaymentBANK-0000928C0000050-381.3-381.3021-Nov-18UNAPPSALESTRUE1371332306
1693301/12/2019Initial EntryInvoiceINV-0004232C00000501226.11226.1004-Dec-19SALESFALSE084033
1793801/12/2019ApplicationPaymentBANK-0000928C0000050-3603604-Oct-19SALESAPPLFALSE077851
1793901/12/2019ApplicationPaymentBANK-0000928C00000501646.11646.1021-Nov-18SALESAPPLFALSE032306
1794001/12/2019ApplicationPaymentBANK-0000928C0000050-384038428-Oct-19SALESAPPLFALSE079816
1794101/12/2019ApplicationPaymentBANK-0000928C0000050-1226.101226.104-Dec-19SALESAPPLFALSE084033
1969701/01/2020Initial EntryInvoiceINV-0004904C0000050444.06444.06004-Jan-20SALESFALSE095060
2026601/01/2020ApplicationInvoiceINV-0004904C0000050444.06444.06021-Nov-18SALESAPPLFALSE032306
2026701/01/2020ApplicationInvoiceINV-0004904C0000050-444.060444.0604-Jan-20SALESAPPLFALSE095060
2064901/02/2020Initial EntryInvoiceINV-0005238C000005014.2214.22004-Feb-20SALESFALSE097627
2070501/02/2020ApplicationPaymentBANK-0000928C0000050278.22278.22021-Nov-18SALESAPPLTRUE2119532306
2070601/02/2020ApplicationPaymentBANK-0000928C0000050-14.22014.2204-Feb-20SALESAPPLTRUE2119697627
2119501/02/2020ApplicationPaymentBANK-0000928C0000050-278.22-278.22021-Nov-18UNAPPSALESTRUE2070532306
2120101/02/2020ApplicationInvoiceINV-0005238C000005014.2214.22021-Nov-18SALESAPPLFALSE032306
2143101/03/2020Initial EntryInvoiceINV-0005460C000005068.468.4004-Mar-20SALESFALSE0101417
2155601/03/2020ApplicationInvoiceINV-0005460C000005068.468.4021-Nov-18SALESAPPLFALSE032306
2155701/03/2020ApplicationInvoiceINV-0005460C0000050-68.4068.404-Mar-20SALESAPPLFALSE0101417

 

7 REPLIES 7
Anonymous
Not applicable

Hi @rs1249

 

I have been studying your issue for quite a few hours,but I still feel confused about how to get the output as you posted.Can you provide more details to make your requirement more clear?

 

Much appreciated.

 

 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

Hi Kelly, thanks very much for look at this for me.

 

there are two tables,

  1. customer ledger table,
  2. detailed customer ledger table.

Customer ledger table recording all the customer ledger transactions such as invoices, credit notes, payments and refund. but there is no linked to show which payments is for which invoice or which refund is to which credit notse.

 

Detailed customer ledger table provides link for it to show which payment is for which invoice.

 

Requirement is to

  1. find the logic behind the link
  2. Following that logic to implement the logic in DAX to show  list of invoices a payment being allocated to

for Customer ledger sample data as below:

Entry_NoCustomer_NoPosting_DateDue_DateDocument_TypeDocument_NoSource_CodeAmountRemaining_Amount
19149C000005001/08/201801/08/2018InvoiceINV-0001041SALES123000
21541C000005001/07/201801/07/2018InvoiceINV-0001092SALES16800
21590C000005001/07/201801/07/2018InvoiceINV-0001106SALES84.860
23732C000005001/08/201801/08/2018InvoiceINV-0001221SALES123000
23956C000005001/08/201801/08/2018InvoiceINV-0001267SALES16800
25472C000005001/09/201801/09/2018InvoiceINV-0001415SALES16800
25475C000005001/09/201801/09/2018InvoiceINV-0001416SALES720
27381C000005030/09/201830/09/2018InvoiceINV-0001536SALES50400
27398C000005030/09/201830/09/2018InvoiceINV-0001537SALES151200
32306C000005021/11/201821/11/2018PaymentBANK-0000928PAYMENTJNL-30240-2710.36
34448C000005007/12/201807/12/2018PaymentBANK-0000988CASHRECJNL-246000
77851C000005001/10/201904/10/2019InvoiceINV-0003860SALES360
79816C000005026/10/201928/10/2019InvoiceINV-0004012SALES3840
84033C000005001/12/201904/12/2019InvoiceINV-0004232SALES1226.10
95060C000005001/01/202004/01/2020InvoiceINV-0004904SALES444.060
97627C000005001/02/202004/02/2020InvoiceINV-0005238SALES14.220
101417C000005001/03/202004/03/2020InvoiceINV-0005460SALES68.40

the detailed customer ledger table as below:

Entry_NoPosting_DateEntry_TypeDocument_TypeDocument_NoCustomer_NoAmountSource_CodeUnappliedUnapplied_by_Entry_NoCust_Ledger_Entry_No
376601/08/2018Initial EntryInvoiceINV-0001041C000005012300SALESFALSE019149
420701/07/2018Initial EntryInvoiceINV-0001092C00000501680SALESFALSE021541
422101/07/2018Initial EntryInvoiceINV-0001106C000005084.86SALESFALSE021590
472601/08/2018Initial EntryInvoiceINV-0001221C000005012300SALESFALSE023732
477101/08/2018Initial EntryInvoiceINV-0001267C00000501680SALESFALSE023956
532901/09/2018Initial EntryInvoiceINV-0001415C00000501680SALESFALSE025472
533001/09/2018Initial EntryInvoiceINV-0001416C000005072SALESFALSE025475
594530/09/2018Initial EntryInvoiceINV-0001536C00000505040SALESFALSE027381
594630/09/2018Initial EntryInvoiceINV-0001537C000005015120SALESFALSE027398
811607/12/2018Initial EntryPaymentBANK-0000988C0000050-24600CASHRECJNLFALSE034448
811707/12/2018ApplicationPaymentBANK-0000988C0000050-12300CASHRECJNLFALSE019149
811807/12/2018ApplicationPaymentBANK-0000988C000005024600CASHRECJNLFALSE034448
811907/12/2018ApplicationPaymentBANK-0000988C0000050-12300CASHRECJNLFALSE023732
878121/11/2018ApplicationPaymentBANK-0000928C0000050-1680SALESAPPLFALSE021541
878321/11/2018ApplicationPaymentBANK-0000928C0000050-84.86SALESAPPLFALSE021590
878421/11/2018ApplicationPaymentBANK-0000928C0000050-1680SALESAPPLFALSE023956
878521/11/2018ApplicationPaymentBANK-0000928C0000050-1680SALESAPPLFALSE025472
878621/11/2018ApplicationPaymentBANK-0000928C0000050-72SALESAPPLFALSE025475
878721/11/2018ApplicationPaymentBANK-0000928C0000050-5040SALESAPPLFALSE027381
878821/11/2018ApplicationPaymentBANK-0000928C0000050-15120SALESAPPLFALSE027398
1539701/10/2019Initial EntryInvoiceINV-0003860C000005036SALESFALSE077851
1600326/10/2019Initial EntryInvoiceINV-0004012C0000050384SALESFALSE079816
1693301/12/2019Initial EntryInvoiceINV-0004232C00000501226.1SALESFALSE084033
1793801/12/2019ApplicationPaymentBANK-0000928C0000050-36SALESAPPLFALSE077851
1794001/12/2019ApplicationPaymentBANK-0000928C0000050-384SALESAPPLFALSE079816
1794101/12/2019ApplicationPaymentBANK-0000928C0000050-1226.1SALESAPPLFALSE084033
1969701/01/2020Initial EntryInvoiceINV-0004904C0000050444.06SALESFALSE095060
2026701/01/2020ApplicationInvoiceINV-0004904C0000050-444.06SALESAPPLFALSE095060
2064901/02/2020Initial EntryInvoiceINV-0005238C000005014.22SALESFALSE097627
2070601/02/2020ApplicationPaymentBANK-0000928C0000050-14.22SALESAPPLTRUE2119697627
2119601/02/2020ApplicationPaymentBANK-0000928C000005014.22UNAPPSALESTRUE2070697627
2120201/02/2020ApplicationInvoiceINV-0005238C0000050-14.22SALESAPPLFALSE097627
2143101/03/2020Initial EntryInvoiceINV-0005460C000005068.4SALESFALSE0101417
2155701/03/2020ApplicationInvoiceINV-0005460C0000050-68.4SALESAPPLFALSE0101417

As you can see from above two tables:

  • The Customer ledger table contains two payments and load invoices, there is no linkage between payment and invoices,
  • The Detailed customer table provides detailed linkage between payments and invoices.

For example for payment 34448, it is applied to Invoice 19149 and 23732 so in the detailed customer ledger transactions it shows as follow:

Entry_NoPosting_DateEntry_TypeDocument_TypeDocument_NoCustomer_NoAmountSource_CodeUnappliedUnapplied_by_Entry_NoCust_Ledger_Entry_No
376601/08/2018Initial EntryInvoiceINV-0001041C000005012300SALESFALSE019149
472601/08/2018Initial EntryInvoiceINV-0001221C000005012300SALESFALSE023732
811607/12/2018Initial EntryPaymentBANK-0000988C0000050-24600CASHRECJNLFALSE034448
811707/12/2018ApplicationPaymentBANK-0000988C0000050-12300CASHRECJNLFALSE019149
811807/12/2018ApplicationPaymentBANK-0000988C000005024600CASHRECJNLFALSE034448
811907/12/2018ApplicationPaymentBANK-0000988C0000050-12300CASHRECJNLFALSE023732

 as you can see when a payment is allocated to the invoices, it generates three consecutive transactions:

811707/12/2018ApplicationPaymentBANK-0000988C0000050-12300CASHRECJNLFALSE019149
811807/12/2018ApplicationPaymentBANK-0000988C000005024600CASHRECJNLFALSE034448
811907/12/2018ApplicationPaymentBANK-0000988C0000050-12300CASHRECJNLFALSE023732

with one offsets itself and two more point at invoices,

I am wondering how I can implement dax to reflect that logic

Anonymous
Not applicable

Hi  @rs1249 ,

 

First create a table as below:

 

Table 2 = ALL('Table'[Cust_Ledger_Entry_No])

 

Then create a calculated column as below:

 

New Document_No = 
IF(SEARCH("BANK",'Table'[Document_No],1,0)>0,'Table'[Document_No],CALCULATE(MIN('Table'[Document_No]),ALLEXCEPT('Table','Table'[Cust_Ledger_Entry_No]))
 
)

 

Finally create 2

 

_Cust_Ledger_Entry_No = 
var _document=MINX(FILTER(ALL('Table'),'Table'[Cust_Ledger_Entry_No]=SELECTEDVALUE('Table 2'[Cust_Ledger_Entry_No])),'Table'[Document_No])
Return
IF(MAX('Table'[New Document_No])=_document,MAX('Table'[Cust_Ledger_Entry_No]),BLANK())

 

measures as below:

 

Measure = IF(MAX('Table'[Entry_Type])="Application"&&'Table'[_Cust_Ledger_Entry_No]<>BLANK(),MAX('Table'[Cust_Ledger_Entry_No]),BLANK())

 

And you will see:

Annotation 2020-06-17 182256.png

For the related .pbix file,pls click here.

 

 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

Hi Kelly, thanks for solution you provided,  it only worked  for that payment, it didn't work for payment in the customer ledger with entry number 32306 though?

32306C000005021/11/201821/11/2018PaymentBANK-0000928PAYMENTJNL-30240-2710.36

 

Anonymous
Not applicable

Hi  @rs1249,

 

The sample data you provided before doesnt contain "32306":

Annotation 2020-06-23 174448.png

Could you pls update your sample data?

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors