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
Anonymous
Not applicable

Cálculo de %

Hola! necesito ayuda con el cálculo de una división porcentual. En particular, tengo una matriz con una primera columna de ciertos productos, luego la cantidad de salas y luego necesito que haya una columna con el porcentaje de esa cantidad sobre el total, pero dependiendo de la región. Probé con la fórmula con la función all y allselected pero por alguna razón que desconozco el valor que me arrojan en el % no es el correcto.

 

Espero puedan ayudarme. Gracias de antemano!

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

Hi, @Anonymous 

 

Try to use the ALLEXCEPT function
I created a simple sample file like below, is this the result you want?

Measures:

_Per of Region =
VAR _countofRoom =
    SUM ( [Count of Room] )
VAR _Region =
    CALCULATE ( SUM ( [Count of Room] ), ALLEXCEPT ( 'Table', 'Table'[Region] ) )
RETURN
    DIVIDE ( _countofRoom, _Region )
_Per of Total =
VAR _count =
    SUM ( 'Table'[Count of Room] )
VAR _total =
    CALCULATE ( SUM ( 'Table'[Count of Room] ), ALL ( 'Table' ) )
RETURN
    DIVIDE ( _count, _total )

vangzhengmsft_0-1623992560305.png

Please refer to the attachment below for details

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng
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

3 REPLIES 3
v-angzheng-msft
Community Support
Community Support

Hi, @Anonymous 

 

Try to use the ALLEXCEPT function
I created a simple sample file like below, is this the result you want?

Measures:

_Per of Region =
VAR _countofRoom =
    SUM ( [Count of Room] )
VAR _Region =
    CALCULATE ( SUM ( [Count of Room] ), ALLEXCEPT ( 'Table', 'Table'[Region] ) )
RETURN
    DIVIDE ( _countofRoom, _Region )
_Per of Total =
VAR _count =
    SUM ( 'Table'[Count of Room] )
VAR _total =
    CALCULATE ( SUM ( 'Table'[Count of Room] ), ALL ( 'Table' ) )
RETURN
    DIVIDE ( _count, _total )

vangzhengmsft_0-1623992560305.png

Please refer to the attachment below for details

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , Assume you have measure M1

 

then

divide([M1], calculate([M1], allselected()) 

or all(Table) will give % of grand total

 

divide([M1], calculate([M1], allexcept(Table, Table[Region]))

, Will use only region filter and give % of region total

 

divide([M1], calculate([M1], filter(allselected(Table), Table[Region] = max(Table[Region])))

same as above , slicer filter will be used

 

Percent of Total- https://www.youtube.com/watch?v=uO3ojDPOpcg&list=PLPaNVDMhUXGZNyKU0PgG2g3P0c6CPjMnj&index=7

Anonymous
Not applicable

muchas gracias por tu respuesta! probé todo lo que mencionas pero sigue sin darme el porcentaje correcto, creo que no es precisamente de un 'total general' (o si hubiese algún problema relacional), pero al calcular una medida aparte del total correcto y visualizarlo en una tarjeta, este valor es correcto, por lo que el problema resultaría al momento de hacer la división para el cálculo del % dentro de la matriz.

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.