Forum Discussion
I"m issue with power bi dax code with error cannot find name
Please help. Here is the code:
Hii NYCDOT
The error occurs because WeekdayNumber is a virtual column created by SELECTCOLUMNS() and exists only in row context. Inside CALCULATE(), filters are evaluated in filter context, so the column cannot be resolved by name. The fix is to store [WeekdayNumber] in a variable and use that variable inside CALCULATE().
3 Replies
- rohit1991
Super User
Hii NYCDOT
The columns created inside ADDCOLUMNS() cannot be referenced by name within the same ADDCOLUMNS() call. [Current Year] and [Previous Year] don’t exist yet when Variance is evaluated. The fix is to use variables inside the same row context or calculate variance in a separate ADDCOLUMNS step. Also ensure you compare numeric weekday columns, not text names.
- NYCDOTRegular Visitor
Thank you for replying. I'm actually having problem with the WeekdayNumber Column. I'm getting an error message state: Column 'WeekdayNumber' cannot be found or may not be used in this expression.
- rohit1991
Super User
Hii NYCDOT
The error occurs because WeekdayNumber is a virtual column created by SELECTCOLUMNS() and exists only in row context. Inside CALCULATE(), filters are evaluated in filter context, so the column cannot be resolved by name. The fix is to store [WeekdayNumber] in a variable and use that variable inside CALCULATE().