Forum Discussion

danielpcamara's avatar
danielpcamara
Icon for Resolver I rankResolver I
2 years ago
Solved

RANKX not working with SELECTEDMEASURE when calculation group is filter

I cant understand why this is not working with a calculated Group: Variable Rank of SELECTEDMEASURE = RANKX(ALL(dEmpresas[Grupo Abrev]), SELECTEDMEASURE ()) but this works (when calculated Group ...
  • danielpcamara's avatar
    2 years ago

    This solves the problem:

     

    1. Rename the Calculation Group table from "Medidas" to "Medidas - Oculto"

    2. Duplicate the table of the Calculation Group, and name this copy to "Medidas"

    3. Rename the "Medida" measure to "Medida Interna" and change the value to:

    Medida Interna = SUMX (
            SUMMARIZE ( dEmpresas, dEmpresas[Grupo Abrev], dEmpresas[CNPJ] ),
            CALCULATE ( AVERAGE ( mIndicadores[QProcessados] ) )
        )

    4. Create a "Medida" measure:

    Medida = CALCULATE(
        [Medida Interna],
        TREATAS(
            VALUES(Medidas[Tipo Medida]),
            'Medidas - Oculto'[Tipo Medida]
        )
    )

    5. Change the code of all Calculated Items:

    IF (
        ISSELECTEDMEASURE ( [Medida Interna] ),
        SUMX (
            SUMMARIZE ( dEmpresas, dEmpresas[Grupo Abrev], dEmpresas[CNPJ] ),
            CALCULATE ( AVERAGE ( ***FILED*** ) )
        ),
        SELECTEDMEASURE ()
    )

     

    6. Hide the calculation group "Medidas - Oculto".

     

    Or just, folow this video to get the same result:

    https://www.youtube.com/watch?v=xS1t25_GsWw