Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I have a table of ~ 70.000 rows, which contains service actions from the past 18 months. I wrote a DAX expression to calculate for each row when the next service action for the same serial number happened. It works, but I keep running into memory allocation failures since I added it to my data model, so I am searching for an alternative way to do the same calculation in a more efficient way.
My current expression:
Next SA = Calculate(
MIN('D Customer Reporting'[Work Order Created On]),
FILTER('D Customer Reporting', 'D Customer Reporting'[Serial Number] = earlier('D Customer Reporting'[Serial Number])),
FILTER('D Customer Reporting', 'D Customer Reporting'[Work Order Created On] > earlier('D Customer Reporting'[Work Order Completed On Date])),
Filter('D Customer Reporting', 'D Customer Reporting'[Incident Type] in {"X", "Z", "Y"}))
Any idea how to do that?
thanks in advance!
Solved! Go to Solution.
Hi @Anonymous
You may try
Next SA =
MINX (
CALCULATETABLE (
'D Customer Reporting',
ALLEXCEPT (
'D Customer Reporting',
'D Customer Reporting'[Serial Number],
'D Customer Reporting'[Work Order Created On]
),
'D Customer Reporting'[Incident Type] IN { "X", "Z", "Y" }
),
'D Customer Reporting'[Work Order Created On]
)
Hi @Anonymous
You may try
Next SA =
MINX (
CALCULATETABLE (
'D Customer Reporting',
ALLEXCEPT (
'D Customer Reporting',
'D Customer Reporting'[Serial Number],
'D Customer Reporting'[Work Order Created On]
),
'D Customer Reporting'[Incident Type] IN { "X", "Z", "Y" }
),
'D Customer Reporting'[Work Order Created On]
)
@Anonymous This may or may not help. Note, you should structure your FILTER statements so that you filter out the most rows first. For example, if filtering to x y and z filters out more records rather than the date filter then that should come first.
Next SA =
VAR __SerialNumber = MAX('D Customer Reporting'[Serial Number])
VAR __WorkCompleted = MAX('D Customer Reporting'[Work Order Completed On Date])
RETURN
CALCULATE(
MIN('D Customer Reporting'[Work Order Created On]),
FILTER('D Customer Reporting', 'D Customer Reporting'[Serial Number] = __SerialNumber) &&
'D Customer Reporting'[Work Order Created On] > __WorkCompleted &&
'D Customer Reporting'[Incident Type] in {"X", "Z", "Y"})
)
Another way:
Next SA = Calculate(
VAR __SerialNumber = MAX('D Customer Reporting'[Serial Number])
VAR __WorkCompleted = MAX('D Customer Reporting'[Work Order Completed On Date])
VAR __Table = FILTER('D Customer Reporting', 'D Customer Reporting'[Serial Number] = __SerialNumber)
VAR __Table1 = FILTER(__Table, [Work Order Created On] > __WorkCompleted)
VAR __Table2 = FILTER(__Table1, [Incident Type] in {"X", "Z", "Y"})
RETURN
MINX(__Table2, [Work Order Created On])
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
27 | |
13 | |
11 | |
9 | |
6 |