Forum Discussion
Power BI - DAX - table variable - use column for further computation
- 5 years ago
EmploymentStatus_SourceTable_CalculatedColumn =
VAR Email = SourceTable[EmployeeEmail]
VAR MaxID = CALCULATE (
MAX(ReferenceTable[InternalID]),
ReferenceTable[EmployeeEmail] = Email
)RETURN
LOOKUPVALUE(
ReferenceTable[EmploymentStatus],
ReferenceTable[EmployeeEmail], Email,
ReferenceTable[InternalID], MaxID
)
Sorry to say that but your code could bring the whole model to a halt when refreshing. The rule is one should not use CALCULATE when creating calculated columns. The main reason for this is that CALCULATE performs a very expensive operation called "context transition" and if you happen to execute this in a big table, you may not live to the end of the processing, figuratively speaking. Good advice from a soldier in the trenches: use my code that does not use CALCULATE.