Forum Discussion
TREATAS with variables as inputs
Anonymous Thanks for letting me know error message using TREATAS Function. Let try using the SUMMARIZE function
VAR A_TreatAs =
TREATAS (
SUMMARIZE(P_B, P_B[ProductKey], P_B[Name], P_B[Brand]),
SUMMARIZE(P_A, P_A[ProductKey], P_A[Name], P_A[Brand])
)
VAR Result =
NATURALLEFTOUTERJOIN ( P_A, A_TreatAs )
RETURN Result The SUMMARIZE function will create temporary tables with the necessary columns, preserving their original names. This should resolve the issue with the TREATAS function. The TREATAS function expects fully qualified column references, and by using SUMMARIZE, you ensure that the column references are in the correct format.
Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!
Let me know if this works
Thanks
- Anonymous2 years agoNot applicable
DallasBaba Still the same issue.
- DallasBaba2 years ago
Skilled Sharer
Anonymous can you share the pbix sample data, or replace the code with the following and check if it works for your specific case.
VAR A_TreatAs = TREATAS ( SUMMARIZE(P_B, P_B[ProductKey], P_B[Name], P_B[Brand]), ADDCOLUMNS( SUMMARIZE(P_A, P_A[ProductKey], P_A[Name], P_A[Brand]), "DummyColumn", 1 ) ) VAR Result = NATURALLEFTOUTERJOIN ( P_A, A_TreatAs ) RETURN ResultNote: A "DummyColumn" will be added to the SUMMARIZE result of P_A to make it a fully qualified table, which can then be used in the TREATAS function. This should bypass the "Function TREATAS expects a fully qualified column reference" error.