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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Amanda_Araujo
Frequent Visitor

Trouble with percentage

I don't know if I'll be able to explain all the details of the data, but I'll try my best. Sorry in advance.

 

The problem is this:

Amanda_Araujo_0-1710439681028.png

The matrix has 4 levels. In the fourth level, percentage is not calculating correctly.
The four levels are from different tables:

Amanda_Araujo_1-1710440558813.png

 

"Categorias" is Ordenação[Ordenação DRE Gerencial]

"Agrupador Nível ll" is ÍNDICE NÍVEL 2[Agrupador Nivel ll]

"Descrição" is Categorias[Descrição]
"Nome Fantansia" is "Cliente/Fornecedor/Transportadora"[Nome Fantansia]

 

Amanda_Araujo_2-1710442108086.png

The relationships

This is the percentage measure:

RB%2 = divide([realizado_correto_categoria],'@Medidas'[Medida KPIS],0)

 

This is the measures mentioned:

Measure 1:

realizado_correto_categoria = 
VAR vArsubtotal = SELECTEDVALUE('ORDENAÇÃO'[Calculado])
RETURN
SWITCH(
    TRUE(),
    vArsubtotal = 0, [Realizado_categorias],
    vArsubtotal <> 0 && NOT(ISINSCOPE('INDICE NÍVEL 2'[Agrupador Nível II])), [Realizado_categorias],
    BLANK()
)Medida KPIS = CALCULATE([Realizado_categorias], Filter(ALL(DE_PARA_CTB),(DE_PARA_CTB[Código Nível II]= "1.1")))Realizado_categorias = var Subtotal = SELECTEDVALUE('ORDENAÇÃO'[Calculado])
    var ordemContexto = Max('ORDENAÇÃO'[Índice])
    var ValorSubtotalresumo = 
    CALCULATE(SUM(Movimentos_unificado[VALOR_USAR]),Filter(ALLNOBLANKROW('ORDENAÇÃO'), 'ORDENAÇÃO'[Índice] <= ordemContexto))
    Return
    SWITCH(
        True(),
        Subtotal = 0, SUM(Movimentos_unificado[VALOR_USAR]),
        Subtotal = 1 && NOT(ISINSCOPE('INDICE NÍVEL 2'[Agrupador Nível II])), ValorSubtotalresumo,
        BLANK()
    )

 

The next:

Realizado_categorias = var Subtotal = SELECTEDVALUE('ORDENAÇÃO'[Calculado])
    var ordemContexto = Max('ORDENAÇÃO'[Índice])
    var ValorSubtotalresumo = 
    CALCULATE(SUM(Movimentos_unificado[VALOR_USAR]),Filter(ALLNOBLANKROW('ORDENAÇÃO'), 'ORDENAÇÃO'[Índice] <= ordemContexto))
    Return
    SWITCH(
        True(),
        Subtotal = 0, SUM(Movimentos_unificado[VALOR_USAR]),
        Subtotal = 1 && NOT(ISINSCOPE('INDICE NÍVEL 2'[Agrupador Nível II])), ValorSubtotalresumo,
        BLANK()
    )

Measure 2:

Medida KPIS = CALCULATE([Realizado_categorias], Filter(ALL(DE_PARA_CTB),(DE_PARA_CTB[Código Nível II]= "1.1")))

 

If it's anything confusing, I can try to explain in more detail. I tried to screenshot the data model, but it looks a mess.

Thanks in advance!

1 REPLY 1
Anonymous
Not applicable

Hi @Amanda_Araujo ,

I think you can check the relationships between tables, ensure that the context and filters are applied correctly. If you can provide more details with your desired output and pbix file without privacy information (or some sample data).

 

 

How to Get Your Question Answered Quickly 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.