Forum Discussion
Anonymous
2 years agoNot applicable
TREATAS with variables as inputs
My struggle to learn and comprehend the intricacies of TREATAS continues (not that I'm complaining, learning is fun). Thanks for solving my previous problem, which was mainly self-inflicted by not...
DallasBaba
Skilled Sharer
2 years agoAnonymous you can use calculated tables
PA =
VAR a = UNION(
SELECTCOLUMNS(P_A, "ProductKey", P_A[ProductKey], "Name", P_A[Name], "Brand", P_A[Brand])
)
VAR b = UNION(
SELECTCOLUMNS(P_B, "Name", P_B[Name], "Brand", P_B[Brand])
)
EVALUATE
VAR A_TreatAs =
TREATAS ( b, a[ProductKey], b[Name], b[Brand] )
VAR Result =
NATURALLEFTOUTERJOIN ( a, A_TreatAs )
RETURN
Result
The above measure will create calculated tables "a" and "b" with the UNION and SELECTCOLUMNS functions to structure the columns as needed.
Let me know if this work
@ me in replies or I'll lose your thread!!!
- Anonymous2 years agoNot applicable
DallasBaba The calculated tables which are the inputs are used to unpivot the example P_A/P_B tables so I cannot use the column names from the P_A table.