cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gauravnarchal
Post Partisan
Post Partisan

Outstanding Invoice total as of Selected Date

Dear All 

 

I need your help to create few measure  as below. Can you please help?

 

I have attached the data for your reference. Thank You for your help in advance.

 

1) If Invoice date & cash receipt date is less than or equal to selected date

AND

Invoice Amount if fully Paid

 

Result

Paid Invoices

 

2) If Invoice is not paid or partially paid as of selected date

 

Result

Sum of Total Outstanding Invoices as of selected date (*For partially paid Invoices only balance should be calculated as of selected date)

 

3) Total Invoice Amount On or Before as of Selected Date

 

4) Total Invoice Amount After as of Selected Date

 

5) Unpaid Invoices as of Selected Date (Outstanding)

 

Download PBIX

1 ACCEPTED SOLUTION

Hi @gauravnarchal ,

 

Please refer to the measure below:

 

 

Paid Invoices or Outstanding Invoices 2 =
VAR SelectedDate =
    MAX ( 'Calendar'[Date] )
VAR ReceiptDate =
    CALCULATE (
        MAX ( Cash_receipt[Receipt_Date] ),
        FILTER (
            Cash_receipt,
            Cash_receipt[invoice_id] = MAX ( ARInvoices[invoice_id] )
        )
    )
RETURN
    IF (
        HASONEVALUE ( ARInvoices[invoice_id] ),
        IF (
            MAX ( ARInvoices[invoice_date] ) <= SelectedDate
                && ReceiptDate <= SelectedDate
                && NOT ( ISBLANK ( ReceiptDate ) ),
            BLANK (),
            CALCULATE (
                SUM ( ARInvoices[InvoiceAmount] ),
                FILTER (
                    ARInvoices,
                    ARInvoices[invoice_date] <= SelectedDate
                        && ARInvoices[invoice_id] IN DISTINCT ( ARInvoices[invoice_id] )
                )
            )
                - CALCULATE (
                    SUM ( Cash_receipt[ReceiptAmount] ),
                    FILTER (
                        Cash_receipt,
                        Cash_receipt[Receipt_Date] <= SelectedDate
                            && Cash_receipt[invoice_id] IN DISTINCT ( ARInvoices[invoice_id] )
                    )
                )
        ),
        [Unpaid Invoices as of Selected Date (Outstanding)]
    )

 

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

6 REPLIES 6
v-deddai1-msft
Community Support
Community Support

Hello @gauravnarchal ,

Please refer to the following measurement for your for 1) and 2):

Paid Invoices or Outstanding Invoices =
VAR SelectedDate =
    MAX ( 'Calendar'[Date] )
VAR ReceiptDate =
    CALCULATE (
        MAX ( Cash_receipt[Receipt_Date] ),
        FILTER (
            Cash_receipt,
            Cash_receipt[invoice_id] = MAX ( ARInvoices[invoice_id] )
        )
    )
RETURN
    IF (
        MAX ( ARInvoices[invoice_date] ) <= SelectedDate
            && ReceiptDate <= SelectedDate
            && NOT ( ISBLANK ( ReceiptDate ) ),
        "Paid Invoices",
        CALCULATE (
            SUM ( ARInvoices[InvoiceAmount] ),
            FILTER (
                ARInvoices,
                ARInvoices[invoice_date] <= SelectedDate
                    && ARInvoices[invoice_id] IN DISTINCT ( ARInvoices[invoice_id] )
            )
        )
            - CALCULATE (
                SUM ( Cash_receipt[ReceiptAmount] ),
                FILTER (
                    Cash_receipt,
                    Cash_receipt[Receipt_Date] <= SelectedDate
                        && Cash_receipt[invoice_id] IN DISTINCT ( ARInvoices[invoice_id] )
                )
            )
    )

And the following measures for 3,4)y5):

Total Invoice Amount On or Before as of Selected Date = VAR SelectedDate = MAX('Calendar'[Date]) Return CALCULATE(SUM(ARInvoices[InvoiceAmount]),FILTER(ALL(ARInvoices),ARInvoices[invoice_date]<=SelectedDate))

Total Invoice Amount After as of Selected Date = VAR SelectedDate = MAX('Calendar'[Date]) Return CALCULATE(SUM(ARInvoices[InvoiceAmount]),FILTER(ALL(ARInvoices),ARInvoices[invoice_date]>=SelectedDate))

Unpaid Invoices as of Selected Date (Outstanding) = VAR SelectedDate = MAX('Calendar'[Date]) return CALCULATE(SUM(ARInvoices[InvoiceAmount]),FILTER(ARInvoices,ARInvoices[invoice_date]<= SelectedDate&&ARInvoices[invoice_id] IN DISTINCT(ARInvoices[invoice_id])))-CALCULATE(SUM(Cash_receipt[ReceiptAmount]),FILTER(Cash_receipt,Cash_receipt[Receipt_Date]<=SelectedDate&&Cash_receipt[invoice_id] IN DISTINCT(ARInvoices[invoice_id])))

Capture.PNG

For more information, see the pbix: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EcdVIyl6dB9HgV98-G...

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

Best regards

Dedmon Dai

@v-deddai1-msft 

How can I filter/remove Paid Invoices from the "Paid Invoices or Outstanding Invoices measure"? The table should only show outstanding Invoices.

 

Thank you for all your help.

 

gauravnarchal_0-1599159934113.png

 

Hi @gauravnarchal ,

 

Just change the measure to show blank:

 

 

Paid Invoices or Outstanding Invoices =
VAR SelectedDate =
    MAX ( 'Calendar'[Date] )
VAR ReceiptDate =
    CALCULATE (
        MAX ( Cash_receipt[Receipt_Date] ),
        FILTER (
            Cash_receipt,
            Cash_receipt[invoice_id] = MAX ( ARInvoices[invoice_id] )
        )
    )
RETURN
    IF (
        MAX ( ARInvoices[invoice_date] ) <= SelectedDate
            && ReceiptDate <= SelectedDate
            && NOT ( ISBLANK ( ReceiptDate ) ),
        Blank(),
        CALCULATE (
            SUM ( ARInvoices[InvoiceAmount] ),
            FILTER (
                ARInvoices,
                ARInvoices[invoice_date] <= SelectedDate
                    && ARInvoices[invoice_id] IN DISTINCT ( ARInvoices[invoice_id] )
            )
        )
            - CALCULATE (
                SUM ( Cash_receipt[ReceiptAmount] ),
                FILTER (
                    Cash_receipt,
                    Cash_receipt[Receipt_Date] <= SelectedDate
                        && Cash_receipt[invoice_id] IN DISTINCT ( ARInvoices[invoice_id] )
                )
            )
    )

 

 

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

 

Best Regards,

Dedmon Dai

Hello @v-deddai1-msft 

 

I have changed the measure as advised. Now i don't see the total when I select any the date after 12th June.

 

I have attached the PBIX.

 

Thank you for the help in advance.

 

Gaurav

 

Download PBIX

Hi @gauravnarchal ,

 

Please refer to the measure below:

 

 

Paid Invoices or Outstanding Invoices 2 =
VAR SelectedDate =
    MAX ( 'Calendar'[Date] )
VAR ReceiptDate =
    CALCULATE (
        MAX ( Cash_receipt[Receipt_Date] ),
        FILTER (
            Cash_receipt,
            Cash_receipt[invoice_id] = MAX ( ARInvoices[invoice_id] )
        )
    )
RETURN
    IF (
        HASONEVALUE ( ARInvoices[invoice_id] ),
        IF (
            MAX ( ARInvoices[invoice_date] ) <= SelectedDate
                && ReceiptDate <= SelectedDate
                && NOT ( ISBLANK ( ReceiptDate ) ),
            BLANK (),
            CALCULATE (
                SUM ( ARInvoices[InvoiceAmount] ),
                FILTER (
                    ARInvoices,
                    ARInvoices[invoice_date] <= SelectedDate
                        && ARInvoices[invoice_id] IN DISTINCT ( ARInvoices[invoice_id] )
                )
            )
                - CALCULATE (
                    SUM ( Cash_receipt[ReceiptAmount] ),
                    FILTER (
                        Cash_receipt,
                        Cash_receipt[Receipt_Date] <= SelectedDate
                            && Cash_receipt[invoice_id] IN DISTINCT ( ARInvoices[invoice_id] )
                    )
                )
        ),
        [Unpaid Invoices as of Selected Date (Outstanding)]
    )

 

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

@v-deddai1-msft - Brilliant..

 

Thank you for your help!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!