Gooner_chef
New Member
- Joined
- Aug 6, 2021
- Messages
- 1
- Office Version
- 365
- Platform
- 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:
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:
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.
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:
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.