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

Correlación en la estructura del producto

Hola

Estoy trabajando en un modelo en el que podría ver la similitud entre los productos a través de la estructura del producto.

La estructura del producto tiene este aspecto:

TopProductComponentPart
1234ABC1
1234BCD2
1234CDE3
1234AABC1
1234AEFG1

Me gustaría trazar una matriz de correlación, como esta

TopProduct12341234A
123410,5
1234A0,331

La respuesta a "?" en la correlación sería cuántos productos en esa parte también estaban en la otra parte.

Espero haber dejado la pregunta clara. ¿Alguien tiene ideas sobre cómo hacer este tipo de cálculo?

Gracias de antemano!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@oscarrudnas - Lo hice así:

Measure 2 = 
    VAR __T = MAX('Table (4)'[TopProduct])
    VAR __T1 = MAX('Table 2'[TopProduct])
    VAR __Parts = SELECTCOLUMNS(FILTER(ALL('Table (4)'),[TopProduct] = __T),"__Parts",[ComponentPart])
    VAR __Parts1 = SELECTCOLUMNS(FILTER(ALL('Table (4)'),[TopProduct] = __T1),"__Parts",[ComponentPart])
    VAR __In = INTERSECT(__Parts,__Parts1)
RETURN
    COUNTROWS(__In) / COUNTROWS(__Parts)

PBIX se adjunta a continuación sig, desea tabla (4) y tabla 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@oscarrudnas - Lo hice así:

Measure 2 = 
    VAR __T = MAX('Table (4)'[TopProduct])
    VAR __T1 = MAX('Table 2'[TopProduct])
    VAR __Parts = SELECTCOLUMNS(FILTER(ALL('Table (4)'),[TopProduct] = __T),"__Parts",[ComponentPart])
    VAR __Parts1 = SELECTCOLUMNS(FILTER(ALL('Table (4)'),[TopProduct] = __T1),"__Parts",[ComponentPart])
    VAR __In = INTERSECT(__Parts,__Parts1)
RETURN
    COUNTROWS(__In) / COUNTROWS(__Parts)

PBIX se adjunta a continuación sig, desea tabla (4) y tabla 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

¡Increíble! ¡Gracias!

Necesidad de entender el código de dax detrás de él todavía, pero eso hizo el truco! ¡Muchas gracias!

@oscarrudnas - Claro, las dos primeras líneas simplemente averiguan dónde estamos en la matriz obteniendo el valor de la fila y la columna. A continuación, creamos dos variables de tabla que filtran las filas de nuestra tabla de hechos base en función de los valores que tenemos para nuestra fila y columna. Usamos SELECTCOLUMNS para obtener la columna que nos interesa.

INTERSECT es la clave, devuelve las filas que son comunes entre la primera tabla y la última tabla. Así que es sólo dividir esto por nuestro recuento de filas.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.