Forum Discussion
Column
- 5 months ago
Hi Snonsup87
The issue occurs because ADDCOLUMNS cannot reference "virtual" columns (like Bucket and RunningHrs) within the same step they are created. To fix this, you must nest the functions so the outer layer can see the columns generated by the inner layer.
Additionally, you should remove the quotation marks from the column names inside the DIVIDE function, as DAX treats quoted text as strings rather than column references.
Recommended DAX Solution
קטע קוד
EVALUATE
ADDCOLUMNS(
ADDCOLUMNS(
SUMMARIZE(
Equipment,
Equipment[Shift Date],
Equipment[Shift Code],
Equipment[ID Operator],
Equipment[Operator Name],
Equipment[Month],
Equipment[Year]
),
"Bucket",
VAR ActualMucking =
CALCULATE(
SUM(BucketbyOperator[Actual Mucking]),
FILTER(
ALL(BucketbyOperator),
BucketbyOperator[Date] = Equipment[Shift Date] &&
BucketbyOperator[Shift] = Equipment[Shift Code] &&
BucketbyOperator[ID Operator] = Equipment[ID Operator]
)
)
RETURN COALESCE(ActualMucking, 0),
"RunningHrs",
CALCULATE(
SUM(Equipment[Duration (Hour)]),
Equipment[Status] = "Ready"
)
),
"TPH",
DIVIDE([Bucket], [RunningHrs], 0)
)
Key Improvements:
Layering: By wrapping the first ADDCOLUMNS in a second one, the TPH calculation now recognizes [Bucket] and [RunningHrs] as valid fields.Performance: Using a variable (VAR) for the Bucket calculation prevents the engine from running the same complex filter twice.
Syntax Correction: Removed the double quotes from DIVIDE("RunningHrs","Bucket") and changed it to DIVIDE([Bucket], [RunningHrs]).
COALESCE: Replaced the IF(...=BLANK(), 0, ...) logic with COALESCE, which is the standard, high-performance way to handle nulls in DAX.
If the logic above does not produce the expected results due to specific relationships in your data model, please upload a sample file (Excel or .PBIX) to a cloud drive (Google Drive, OneDrive, etc.) with a clear example of your desired output and share the link here.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
Hi Snonsup87,
Thank you for reaching out to Microsoft Fabric Community.
Thank you FBergamaschi and Ritaf1983 for the prompt response.
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the user's for the issue worked? or let us know if you need any further assistance.
Thanks and regards,
Anjan Kumar Chippa
Hi @Snonsup87,
We wanted to kindly follow up to check if the solution provided by the user's for the issue worked? or let us know if you need any further assistance.
Thanks and regards,
Anjan Kumar Chippa