Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Rankx on virtual tables return only 1

Hello guys   I am trying within one measure to generate the ranking by country based on ACT vs BUD. The fact table and the dimension table DimEntities are connected in the model. The fact table h...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi guys

     

    I think i found the solution:

    VAR _tmpTable = SUMMARIZE(ALLSELECTED('Fact'), DimEntities[Country],  "Value1", [ACT Vs BUD])
    VAR _curCountry = SELECTEDVALUE(DimEntities[Country])
    VAR _rankedTable = ADDCOLUMNS(FILTER(_tmpTable, [Country] <> BLANK()), "rank",
        RANKX(_tmpTable,  [Value1], ,DESC,Skip))
    RETURN
    MAXX(FILTER(_rankedTable,  [Country] = _curCountry ),  [rank])

    My inspiration came from this post: 
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi guys

    Following this idea 

    I have been able to solve my current problem.
    This measure is now working:
    Ranking based on RANK 2h WORKING =
    VAR _tmpTable = SUMMARIZE(ALLSELECTED('Fact'), DimEntities[Country],  "Value1", [ACT Vs BUD])
    VAR _curCountry = SELECTEDVALUE(DimEntities[Country])
    VAR _rankedTable = ADDCOLUMNS(FILTER(_tmpTable, [Country] <> BLANK()), "rank",
        RANKX(_tmpTable,  [Value1], ,DESC,Skip))
    RETURN
    MAXX(FILTER(_rankedTable,  [Country] = _curCountry ),  [rank])
     
    Cheers & thanks for your help