Forum Discussion

AgencyPowerBi's avatar
AgencyPowerBi
Helper III
3 years ago
Solved

Referencing table as a variable

Hi guys, I'm stuck with this and getting opposing information online. I'm wondering can I make calculated table through use of variable? Code is like this:   EVALUATE VAR Table1 =     FILTER ( ...
  • tamerj1's avatar
    tamerj1
    3 years ago

    AgencyPowerBi 

    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