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
Banistas
Helper I
Helper I

Crear medida excluyendo la selección actual

Hola

Quiero crear una medida que haga un cálculo excluyendo la selección actual de ella.

Más fácil de explicar con un ejemplo simple, así que aquí voy.

Supongamos que tengo la siguiente tabla de datos:

Personas

Número de mascotas

Lucy

6

Gabi

2

Martin

3

And now, let say I want to create a measure named Número de mascotas que nos excluyen that will sum the Número de mascotas for all the Personas, excluding the one that is "currently" selected. So, I want o end up with a Simple Table that displays as follows:

Personas

Número de mascotas que nos excluyen

Lucy

5

Gabi

9

Martin

8

Where the Número de mascotas que nos excluyen was 5 for Lucy (Gabi has 2 + Martin has 3), 9 for Gabi (Lucy has 6 + Martin has 3), and 8 for Martin (Lucy has 6 + Gabi has 2).

¿Cómo se puede lograr esto?

Gracias.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hola @Banistas

Algo a lo largo de estas líneas usando la función EXCEPT debe funcionar, suponiendo que usted tiene una medida [Número de mascotas]:

Number of Pets Excluding You =
CALCULATE (
    [Number of Pets],
    EXCEPT ( ALL ( YourTable[Persons] ), VALUES ( YourTable[Persons] ) )
)

El uso de ALL ( YourTable[Persons] ) garantiza que siempre obtendrá el total de todas las personas que no sean las personas filtradas. Puede considerar ALLSELECTED si hay un filtro externo en las personas que desea usar en lugar de todas las personas en el conjunto de datos.

saludos

Owen

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Banistas , Crear una medida como esta y tratar de

calculate(sum(Table[Number of Pets]), all(Table))- sum(Table[Number of Pets])

Proporcione sus comentarios y consejos para nuevos videos
Tutorial Series Dax Vs SQL Direct Query PBI Consejos
Apreciamos tus Felicitaciones.

Anonymous
Not applicable

Hola @Banistas

Algo a lo largo de estas líneas usando la función EXCEPT debe funcionar, suponiendo que usted tiene una medida [Número de mascotas]:

Number of Pets Excluding You =
CALCULATE (
    [Number of Pets],
    EXCEPT ( ALL ( YourTable[Persons] ), VALUES ( YourTable[Persons] ) )
)

El uso de ALL ( YourTable[Persons] ) garantiza que siempre obtendrá el total de todas las personas que no sean las personas filtradas. Puede considerar ALLSELECTED si hay un filtro externo en las personas que desea usar en lugar de todas las personas en el conjunto de datos.

saludos

Owen

Thanks @Anonymous. This does exactly what I needed, and can be applied for cases where there are calculations other than SUM which is brilliant. 

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.