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
Luisevar12
New Member

Columna para saber si utiliza uno o ambos elementos.

Estoy buscando la forma de crear la tercera columna "Resumen" para saber si los países producen ambos tipos, (si detecta que por ejemplo colombia tiene hierro y cobre) o si sólo detecta uno, el nombre del elemento que usa.

Dejo el ejemplo abajo

PaisTipo de elementoResumen
ColombiaHierroAmbos
GreciaHierroHierro
Costa RicaCobreCobre
ColombiaCobreAmbos
Grecia HierroHierro
ArgentinaCobreCobre

 

He visto ejemplos parecidos pero no logro hacerlo de esa manera.

 

¿Me ayudan?

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

Hi @Luisevar12 ,

 

Try this code to create [Resumen] column in your table.

Resumen = 
VAR _cnt =
    CALCULATE (
        DISTINCTCOUNT ( 'Tabla'[Tipo de elemento] ),
        ALLEXCEPT ( 'Tabla', Tabla[Pais] )
    )
RETURN
    IF ( _cnt = 2, "Ambos", Tabla[Tipo de elemento] )

Result is as below.

RicoZhou_0-1675406192672.png

 

Best Regards,
Rico Zhou

 

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

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @Luisevar12 ,

 

Try this code to create [Resumen] column in your table.

Resumen = 
VAR _cnt =
    CALCULATE (
        DISTINCTCOUNT ( 'Tabla'[Tipo de elemento] ),
        ALLEXCEPT ( 'Tabla', Tabla[Pais] )
    )
RETURN
    IF ( _cnt = 2, "Ambos", Tabla[Tipo de elemento] )

Result is as below.

RicoZhou_0-1675406192672.png

 

Best Regards,
Rico Zhou

 

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

@Luisevar12 , Try like

new column =
var _cnt = calculate(distinctCOUNT(Table[Tipo de elemento]),filter(Table, Table[Pais] = max(Table[Pais]) && Table[Pais] in{"Hierro", "Cobre"} ))
return
if(_cnt =2, "Both", [Pais])

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.