Forum Discussion
felipefrutuoso
5 years agoFrequent 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] ...
- 5 years ago
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.
edhans
Community Champion
5 years agoYou 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.