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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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