Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
dlopesc04
Resolver II
Resolver II

Problem with RANKX and ISINSCOPE returning only 1 on every level

I'm attaching a pbix file with some mock data but below are prints of my actual file and error, I'm truly at my wits end and cannot figure out why this measure is not working:

dlopesc04_0-1730493295486.png

Dax:

_1 Ranks = 
VAR is_inscope_tipo = ISINSCOPE('TAB_BD_UNIFICADA13'[Tipo/Conjunto])
VAR is_inscope_familia = ISINSCOPE('TAB_BD_UNIFICADA13'[Família Equip.])
VAR is_inscope_equipamento = ISINSCOPE('TAB_BD_UNIFICADA13'[Equipamento/Local (Onde)])
VAR is_inscope_item = ISINSCOPE('TAB_BD_UNIFICADA13'[Item/Componente])

VAR ranking = SWITCH(
    TRUE(),
    is_inscope_tipo,
        RANKX(ALLSELECTED('TAB_BD_UNIFICADA13'[Tipo/Conjunto]),
            [_Impacto_Total]
        ),
    is_inscope_familia,
        RANKX(ALLSELECTED('TAB_BD_UNIFICADA13'[Família Equip.]),
            [_Impacto_Total]
        ),
    is_inscope_equipamento,
        RANKX(ALLSELECTED('TAB_BD_UNIFICADA13'[Equipamento/Local (Onde)]),
            [_Impacto_Total]
        ),
    is_inscope_item,
        RANKX(ALLSELECTED('TAB_BD_UNIFICADA13'[Item/Componente]),
            [_Impacto_Total]
        ),0
)
RETURN
ranking


Link to drive with pbix:
https://drive.google.com/file/d/1hImXInqrsJgEfSQvcFU_5M1wsu5AAgLw/view?usp=sharing

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

pls try this
you did the ISINSCOPE order in SWITCH incorrectly, you need to start from the bottom

 

_1 Ranks = 
VAR is_inscope_tipo = ISINSCOPE('TAB_BD_UNIFICADA13'[Tipo/Conjunto])
VAR is_inscope_familia = ISINSCOPE('TAB_BD_UNIFICADA13'[Família Equip.])
VAR is_inscope_equipamento = ISINSCOPE('TAB_BD_UNIFICADA13'[Equipamento/Local (Onde)])
VAR is_inscope_item = ISINSCOPE('TAB_BD_UNIFICADA13'[Item/Componente])

VAR ranking = SWITCH(
    TRUE(),
        is_inscope_item,
        RANKX(ALLSELECTED('TAB_BD_UNIFICADA13'[Item/Componente]),
            [_Impacto_Total],,DESC,Dense
        ),
        is_inscope_equipamento,
        RANKX(ALLSELECTED('TAB_BD_UNIFICADA13'[Equipamento/Local (Onde)]),
            [_Impacto_Total],,DESC,Dense
        ),
            is_inscope_familia,
        RANKX(ALLSELECTED('TAB_BD_UNIFICADA13'[Família Equip.]),
            [_Impacto_Total],,DESC,Dense
        ),
    is_inscope_tipo,
        RANKX(ALLSELECTED('TAB_BD_UNIFICADA13'[Tipo/Conjunto]),
            [_Impacto_Total],,DESC,Dense
        )
,0
)
RETURN
ranking

 

View solution in original post

4 REPLIES 4
Ahmedx
Super User
Super User

pls try this
you did the ISINSCOPE order in SWITCH incorrectly, you need to start from the bottom

 

_1 Ranks = 
VAR is_inscope_tipo = ISINSCOPE('TAB_BD_UNIFICADA13'[Tipo/Conjunto])
VAR is_inscope_familia = ISINSCOPE('TAB_BD_UNIFICADA13'[Família Equip.])
VAR is_inscope_equipamento = ISINSCOPE('TAB_BD_UNIFICADA13'[Equipamento/Local (Onde)])
VAR is_inscope_item = ISINSCOPE('TAB_BD_UNIFICADA13'[Item/Componente])

VAR ranking = SWITCH(
    TRUE(),
        is_inscope_item,
        RANKX(ALLSELECTED('TAB_BD_UNIFICADA13'[Item/Componente]),
            [_Impacto_Total],,DESC,Dense
        ),
        is_inscope_equipamento,
        RANKX(ALLSELECTED('TAB_BD_UNIFICADA13'[Equipamento/Local (Onde)]),
            [_Impacto_Total],,DESC,Dense
        ),
            is_inscope_familia,
        RANKX(ALLSELECTED('TAB_BD_UNIFICADA13'[Família Equip.]),
            [_Impacto_Total],,DESC,Dense
        ),
    is_inscope_tipo,
        RANKX(ALLSELECTED('TAB_BD_UNIFICADA13'[Tipo/Conjunto]),
            [_Impacto_Total],,DESC,Dense
        )
,0
)
RETURN
ranking

 

First off, your measure works, but I found something else out, I have a filter on my visual to not show blank values, when putting your measure in it with this filter on it looks like this:

dlopesc04_0-1730723601076.png

(Show values when isn't blank)

dlopesc04_2-1730723654742.png

No filter (correct).


Which kinda sucks. Anyways, thanks for the help.

I can't say specifically what the problem is, but I think the blank here is also shadowed, so they need to be excluded.

HotChilli
Super User
Super User

Have you tested to see what is actually in scope on each row of the matrix?

Suggest you create 4 test measures (1 for each isinscope) and add them to the matrix. You'll then be able to confirm if your main measure is doing what you think it is. And if not, possibly a rewrite of the SWITCH is required.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.