Forum Discussion
Referencing table as a variable
- 3 years ago
Sorry. Typo mistake. Don't use the table reference only use the column reference as temporary tables cannot be referenced. It should work.
EVALUATE
VAR Table1 =
FILTER (
SUMMARIZE (
FILTER ( '_SOURCE CARS', '_SOURCE CARS'[Year] = 2022 ),
Brand_Prodaja[Brand_Promocija],
Datumi[ISO week],
"TRP", [Sum of All 18-54 I&G GRP]
),
[TRP] > 25
&& [Brand_Promocija] <> "Ništa"
)
VAR Result =
ADDCOLUMNS (
GROUPBY (
Table1,
[Brand_Promocija],
"Active weeks", COUNTX ( CURRENTGROUP (), [TRP] ),
"Total TRP", SUMX ( CURRENTGROUP (), [TRP] )
),
"TRP/Week", DIVIDE ( [Total TRP], [Active weeks] )
)
RETURN
Result
Nope,
Table1[Brand_Promocija] cannot be found in the input table.
Also all [TRP] instances are also cannot be referenced.
That is what is puzzeling.
What could be the problem?
If I make two separate tables, everything works 😞
I guess I have to use iteration functions?
Sorry. Typo mistake. Don't use the table reference only use the column reference as temporary tables cannot be referenced. It should work.
EVALUATE
VAR Table1 =
FILTER (
SUMMARIZE (
FILTER ( '_SOURCE CARS', '_SOURCE CARS'[Year] = 2022 ),
Brand_Prodaja[Brand_Promocija],
Datumi[ISO week],
"TRP", [Sum of All 18-54 I&G GRP]
),
[TRP] > 25
&& [Brand_Promocija] <> "Ništa"
)
VAR Result =
ADDCOLUMNS (
GROUPBY (
Table1,
[Brand_Promocija],
"Active weeks", COUNTX ( CURRENTGROUP (), [TRP] ),
"Total TRP", SUMX ( CURRENTGROUP (), [TRP] )
),
"TRP/Week", DIVIDE ( [Total TRP], [Active weeks] )
)
RETURN
Result