I have 2 problems :
- When running the code below with DaxStudio, I get an error along the lines of "TREATAS function expects a complete column reference" ; How can I implement data lineage with table variables not coming from a table of a data model?
- Is there a simple way of adding to
tbl_ITEMS_REFS
the consolidated sum oftbl_SALES[AMOUNT]
?
The code :
EVALUATE
VAR tbl_SALES =
DATATABLE(
"SALES_NBR" , INTEGER
, "ITEM_CODE" , STRING
, "AMOUNT" , INTEGER
, {
{ 1 , "X" , 10 }
, { 2 , "Y" , 10 }
, { 3 , "Z" , 10 }
, { 4 , "X" , 20 }
, { 5 , "Z" , 20 }
, { 6 , "Z" , 10 }
, { 7 , "Z" , 20 }
, { 8 , "X" , 30 }
, { 9 , "X" , 30 }
, { 10 , "Y" , 30 }
}
)
VAR tbl_ITEMS_REFS =
DATATABLE(
"Origin" , STRING
, "Code" , STRING
, {
{" Department 1 " , "X"}
, {" Department 1 " , "Y"}
, {" Department 2 " , "Z"}
}
)
VAR tbl_ITEMS_DATA_LINEAGE =
TREATAS (
SELECTCOLUMNS ( tbl_ITEMS_REFS , [Code] )
, SELECTCOLUMNS ( tbl_SALES , [ITEM_CODE] )
)
RETURN
ADDCOLUMNS (
tbl_ITEMS_DATA_LINEAGE
, "Total_Sales"
, CALCULATE (
SUM ( [AMOUNT] )
)
)
Thank you for your help.
Addendum
For question 2, by "adding to tbl_ITEMS_REFS
", I was thinking of a simple way to get something like this :
Department 1 X 90
Department 1 Y 40
Department 2 Z 60