Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
OlivierPag
Regular Visitor

Error when I want to create a measure with a temporary table

Hello

I wants to create a measure based on a temporary table but despite all my effort I still have the same error
Table variable 'Rend' cannot be used in current context because a base table is expected.

The code is this one

 

Measure2 =
VAR Rend = ADDCOLUMNS(
SUMMARIZE(
control_result,
control_result[campaign]),
"comment",CALCULATE(DISTINCTCOUNTNOBLANK(control_result[controlresultid]),control_result[approver_comment]<10,control_result[performer_comment]<10),
"orby", LOOKUPVALUE(Campaign_Sort[Sort By],Campaign_Sort[Campaign],Rend[campaign]))

VAR numerateur = sumx(Rend,(Rend[orby]-AVERAGE(Rend[orby]))*(Rend[comment]-AVERAGE(Rend[comment])))
VAR Denominateur = sumx(Rend,(Rend[orby]-AVERAGE(Rend[orby]))*(Rend[orby]-AVERAGE(Rend[orby])))

RETURN
IF (DIVIDE(numerateur,Denominateur)<0,
"↓",
IF(DIVIDE(numerateur,Denominateur)>0,"↑","→"))
1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can't refer to columns from a variable by using the TableName[ColumnName] syntax, you have to just use [ColumnName]. Try

Measure2 =
VAR Rend =
    ADDCOLUMNS (
        SUMMARIZE ( control_result, control_result[campaign] ),
        "comment",
            CALCULATE (
                DISTINCTCOUNTNOBLANK ( control_result[controlresultid] ),
                control_result[approver_comment] < 10,
                control_result[performer_comment] < 10
            ),
        "orby", LOOKUPVALUE ( Campaign_Sort[Sort By], Campaign_Sort[Campaign], Rend[campaign] )
    )
VAR numerateur =
    SUMX (
        Rend,
        ( [orby] - AVERAGEX ( Rend, [orby] ) )
            * ( [comment] - AVERAGEX ( Rend, [comment] ) )
    )
VAR Denominateur =
    SUMX (
        Rend,
        ( [orby] - AVERAGEX ( Rend, [orby] ) )
            * ( [orby] - AVERAGEX ( Rend, [orby] ) )
    )
RETURN
    IF (
        DIVIDE ( numerateur, Denominateur ) < 0,
        "↓",
        IF ( DIVIDE ( numerateur, Denominateur ) > 0, "↑", "→" )
    )

View solution in original post

2 REPLIES 2
OlivierPag
Regular Visitor

Thank you it works

johnt75
Super User
Super User

You can't refer to columns from a variable by using the TableName[ColumnName] syntax, you have to just use [ColumnName]. Try

Measure2 =
VAR Rend =
    ADDCOLUMNS (
        SUMMARIZE ( control_result, control_result[campaign] ),
        "comment",
            CALCULATE (
                DISTINCTCOUNTNOBLANK ( control_result[controlresultid] ),
                control_result[approver_comment] < 10,
                control_result[performer_comment] < 10
            ),
        "orby", LOOKUPVALUE ( Campaign_Sort[Sort By], Campaign_Sort[Campaign], Rend[campaign] )
    )
VAR numerateur =
    SUMX (
        Rend,
        ( [orby] - AVERAGEX ( Rend, [orby] ) )
            * ( [comment] - AVERAGEX ( Rend, [comment] ) )
    )
VAR Denominateur =
    SUMX (
        Rend,
        ( [orby] - AVERAGEX ( Rend, [orby] ) )
            * ( [orby] - AVERAGEX ( Rend, [orby] ) )
    )
RETURN
    IF (
        DIVIDE ( numerateur, Denominateur ) < 0,
        "↓",
        IF ( DIVIDE ( numerateur, Denominateur ) > 0, "↑", "→" )
    )

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.