Forum Discussion

rui_silva's avatar
rui_silva
Icon for Helper I rankHelper I
8 years ago
Solved

RANKX showing duplicated values

Hi,

I getting a issue where when i try to use RANKX to rank some data im getting duplicated values 

Measure im using : rankx(allselected(Dados[Turmas/Ano]); calculate(SUMX(Dados;Dados[MódulosAtraso]));;;Skip)

Sample Data:

School     NameofClass  MódulosAtraso  Rank

Porto          Class1                   900               1

Viseu          Class10                 560               1

Porto          Class20                 820               2

Viseu          Class4                   400               2

 

Expected Result would be:

School    NameofClass       MóduloAtraso      Rank

Porto           Class1                    900                   1               

Porto           Class10                  820                   2

Viseu           Class20                  560                   3

Viseu           Class4                    400                   4

 

OBS : Each school has unique ID for example :

SchoolID School

1                Porto

2                Viseu

  • tex628 Thanks for all the help i already found a way to show the information i wanted so instead of using my SchoolName i used the ClassID and now its showing the results i wanted .

    As my ClassID they have schools names abbreviated as for examples PORGpsi1619 , i made table with the abreviattions and the school names so in the meetups people can understand what the 3 first letters means 

     

     

11 Replies

  • Phil_Seamark's avatar
    Phil_Seamark
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi rui_silva

     

    This calculated column matches your expected results

     

    My Rank = RANKX('Table','Table'[MódulosAtraso])
    • rui_silva's avatar
      rui_silva
      Icon for Helper I rankHelper I

      Hey thanks for helping me but when i try use your function it gives me a error :

      A single value for column 'MódulosAtraso' in table 'Dados' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

  • Anonymous's avatar
    Anonymous
    Not applicable

    May try to use the following DAX, add more conditions in ALL functions

     

    Rank = RANKX(ALL(School[NameofClass],School[School]),CALCULATE(SUM(School[MódulosAtraso])),,DESC)

     

    • rui_silva's avatar
      rui_silva
      Icon for Helper I rankHelper I

      Anonymous hey thanks for the help but when i use your formula it gives me a error :

      All column arguments of the ALL/ALLNOBLANKROW function must be from the same table.

       

      This is my relationship if it helps :

      Im going to translate the tables because they are in portuguese so table "Escola" = School where u have IdSchool and SchoolName

      "Turmas"="ClassData" in this table is where i get have my table with all ids matching up .

      "Dados" = "Class" where i have ClassName and MódulosAtraso 

       

       

      • tex628's avatar
        tex628
        Icon for Community Champion rankCommunity Champion

        May I ask what is the purpose of creating this ranking, is it to filter on rank or simply to display the rank?

         

        / J