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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DDalmas
Frequent Visitor

Calcular % por operador

Tenho uma passa de dados onde cada linha é uma infração cometida por um motorista.

 

Essas infrações elas passam por um operador que faz a validação se essa infração é válida ou não. O que acontece, eu queria montar um gráfico onde mostra o % de infrações tratadas por cada operador.

 

eu faço o calculo do percentual (Divido o total tratado pelo total de infrações), dai eu coloco o nome dos operadores como eixo e o valor, porém o que ocorre é que o gráfico distribui o mesmo % para todos os operadores, ficando todos os operadores com 20%, onde na verdade eu queria que operador A ficasse com 15%, operador B 3% e o C 2%, por exemplo.

 

E esse % precisaria ser em cima do total tratado com relação ao total de infrações. ex:
Esse é o cenário que eu preciso:
tenho 100 infrações, dessas 20 foram validadas (20% das infrações foram tratadas)
forem desses 20% operador A tratou 12%, operador B tratou 5% e operador C tratou 3%.

 

 

Uma alternativa que encontrei foi montar uma tabela auxiliar onde eu tenho o Operador, o total de infrações geral, o total de infrações validadas geral, o total de infrações validadas pelo operador e ai eu consigo calcular esse % tratado por operador com relação ao total de infrações tratadas, porem essa alternativa faz com que eu perca a interação do gráfico com os filtros pois estou tratando isso numa tabela apenas com o nome dos operadores.

 

 

existe alguma forma de fazer esse calculo sem ser por essa tabela auxiliar pra que eu possa retornar a interação do gráfico com os demais filtros do relatório? pois da forma como cheguei nem o filtro de periodo eu consigo aplicar.

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @DDalmas  ,

Created some data:

v-yangliu-msft_0-1620632511137.png

Here are the steps you can follow:

1. Create measure.

Total:

sumtotal = COUNTX(ALL('Table'),'Table'[Operator])

Total number of violations:

sumYes = COUNTAX(FILTER(ALL('Table'),'Table'[Violation]="Yes"),'Table'[Violation])

Total after violation group:

group = CALCULATE(COUNT('Table'[Violation]),FILTER(ALL('Table'),'Table'[Violation]="Yes"&&'Table'[Operator]=MAX('Table'[Operator])))

The total number of violations as a percentage of the total:

sum/total = DIVIDE([sumYes],[sumtotal])

Proportion of the total number after the violation group to the total number of violations:

sum/groupo = DIVIDE([group],[sumYes])

2. Result:

When no slicer is selected:

v-yangliu-msft_1-1620632511142.png

After selecting the slicer:

v-yangliu-msft_2-1620632511145.png

If this result does not meet your expectations, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

 

Best Regards,

Liu Yang

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

View solution in original post

1 REPLY 1
v-yangliu-msft
Community Support
Community Support

Hi  @DDalmas  ,

Created some data:

v-yangliu-msft_0-1620632511137.png

Here are the steps you can follow:

1. Create measure.

Total:

sumtotal = COUNTX(ALL('Table'),'Table'[Operator])

Total number of violations:

sumYes = COUNTAX(FILTER(ALL('Table'),'Table'[Violation]="Yes"),'Table'[Violation])

Total after violation group:

group = CALCULATE(COUNT('Table'[Violation]),FILTER(ALL('Table'),'Table'[Violation]="Yes"&&'Table'[Operator]=MAX('Table'[Operator])))

The total number of violations as a percentage of the total:

sum/total = DIVIDE([sumYes],[sumtotal])

Proportion of the total number after the violation group to the total number of violations:

sum/groupo = DIVIDE([group],[sumYes])

2. Result:

When no slicer is selected:

v-yangliu-msft_1-1620632511142.png

After selecting the slicer:

v-yangliu-msft_2-1620632511145.png

If this result does not meet your expectations, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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