Adding a measure to SUM 'passed due' payments

Gooner_chef

New Member
Joined
Aug 6, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi there,

I have a FACT table which contains payment due amount and due date (due date is a link to a DIM_DATE dimension table).

I have a requirement to add a new measure to the fact table, sums the total amount of 'passed due' payment due amounts (i.e. where for the current row, summarizes all payment amounts where due date is less than the current selected date).

My model looks as follows:

1628266825438.png


The actual date value is stored in [DIM_DATE].Gregoriandate.

I can achieve something similar in SQL by using a subquery which contains a group by, as follows:

SQL:
SELECT
    ct1.ACCOUNTNUM,
    dim1.DateRecID,
    SUM([AMOUNTCUR]) as AmountDue,
        (
            SELECT
                SUM(AMOUNTCUR)
            FROM FACT_CUST_TRANS  ct2
                INNER JOIN common.dim_date dim2 ON ct2.[DUEDATE] = dim2.GREGORIANDATE
            WHERE (ct1.ACCOUNTNUM = ct2.ACCOUNTNUM) 
            AND (ct2.DUEDATE < ct1.DUEDATE)
        ) As AmountPassedDue
FROM FACT_CUST_TRANS ct1
    INNER JOIN common.dim_date dim1 ON ct1.[DUEDATE] = dim1.GREGORIANDATE
GROUP BY ACCOUNTNUM, dim1.DateRecID, ct1.DUEDATE

Could anyone provide some guidance as to how I can achieve something similar in PowerBI using DAX?

Any help would be much appreciated.

Thanks in advance.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top