Forum Discussion
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"
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 ResultSee if that works for you.
1 Reply
- edhans
Community Champion
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 ResultSee if that works for you.