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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
felipefrutuoso
Frequent Visitor

rankx using column of variable table

Why I cannot do this?

EVALUATE
VAR myvirtuatable = ADDCOLUMNS(
    SUMMARIZE(
        FILTER('table_a',[field]=666),        
        'table_a'[field2],
        'table_a'[field3]
             ),
    "total", CALCULATE(sum('table_a'[value]))
        )

RETURN ADDCOLUMNS(myvirtuatable,"RANK",RANKX(myvirtuatable,total,,DESC))

"cannot find this name, "total"

1 ACCEPTED SOLUTION
edhans
Super User
Super User

You can, your syntax is off just a bit though @felipefrutuoso 

When you create a table using a variable, if the function can see the table (iterators can, aggregators cannot), the field name has to be wrapped in square brackets.

 

EVALUATE
VAR myvirtuatable =
    ADDCOLUMNS(
        SUMMARIZE(
            FILTER(
                'table_a',
                [field] = 666
            ),
            'table_a'[field2],
            'table_a'[field3]
        ),
        "total",
            CALCULATE(
                SUM( 'table_a'[value] )
            )
    )
VAR Result = 

    ADDCOLUMNS(
        myvirtuatable,
        "RANK",
            RANKX(
                myvirtuatable,
                [total],   <---- Adjustment to syntax
                ,
                DESC
            )
    )
RETURN
	Result

See if that works for you.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

1 REPLY 1
edhans
Super User
Super User

You can, your syntax is off just a bit though @felipefrutuoso 

When you create a table using a variable, if the function can see the table (iterators can, aggregators cannot), the field name has to be wrapped in square brackets.

 

EVALUATE
VAR myvirtuatable =
    ADDCOLUMNS(
        SUMMARIZE(
            FILTER(
                'table_a',
                [field] = 666
            ),
            'table_a'[field2],
            'table_a'[field3]
        ),
        "total",
            CALCULATE(
                SUM( 'table_a'[value] )
            )
    )
VAR Result = 

    ADDCOLUMNS(
        myvirtuatable,
        "RANK",
            RANKX(
                myvirtuatable,
                [total],   <---- Adjustment to syntax
                ,
                DESC
            )
    )
RETURN
	Result

See if that works for you.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.