Forum Discussion

felipefrutuoso's avatar
felipefrutuoso
Frequent Visitor
5 years ago
Solved

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]             ...
  • edhans's avatar
    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
    	Result

    See if that works for you.