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

Top N con valores estáticos

Hola

 

Tengo una tabla de dimensiones con los atributos de un producto, y otra tabla (de dimensiones también) con los almacenes donde se vende.

 

Se requiere generar inicialmente un top de cuales son lon productos que más se venden a nivel general. Para el ejemplo tengo un top de los 3 productos que mas se venden.

 

ProductValue
Product A$ 16,500.00
Product B$ 3,200.00
Product C$ 1,800.00
Total$ 21,500.00

 

Luego se necesita generar una matriz donde se indique de esos productos seleccionados, la distribución por almacén de los mismos. Se debe obtener el siguiente resultado.

 

WarehouseProductValue
Warehouse 2Product A$ 10,000.00
Warehouse 3Product B$ 500.00
Warehouse 4Product C$ 100.00
Warehouse 3Product A$ 5,000.00
Warehouse 4Product B$ 1,700.00
Warehouse 5Product C$ 600.00
Warehouse 4Product A$ 1,500.00
Warehouse 5Product B$ 1,000.00
Warehouse 6Product C$ 1,100.00
Total $ 21,500.00


Pero al momento de calcular la matriz, está apareciendo el top de los productos por cada almacén, y se muestran los productos QUE NO ESTÁN en el filtro inicial (A, B, C). El valor total SI ESTÁ BIEN, pero el detalle no (los productos X, Y, Z ni siquiera deben aparecer).

 

WarehouseProductValue
Warehouse 2Product A$ 3,800.00
Warehouse 3Product B$ 2,500.00
Warehouse 4Prodcut Z$ 589.00
Warehouse 3Product X$ 8,792.00
Warehouse 4Product Y$ 4,256.00
Warehouse 5Product A$ 2,587.00
Warehouse 4Product C$ 950.00
Warehouse 5Product B$ 671.00
Warehouse 6Prodcut Z$ 645.00
Total**Real value 24,790**$ 21,500.00

 

He utilizado las funciones de RANK(), TOPN para calcular los valores. Y cuando creo que va a salir el cálculo este se rompe. Esta es la fórmula que utilicé.

 

 

 

 

VALOR_INICIAL_TOP_N_ORIG = 
VAR TOP_TABLA = TOPN(3, ALLSELECTED(AUX_MARCA), [#VALOR_HECHOS_INICIAL])
VAR VALOR_TABLA = CALCULATE([#VALOR_HECHOS_INICIAL], KEEPFILTERS(TOP_TABLA))
RETURN
VALOR_TABLA

 

 

 

 

Agradezco su colaboración para resolver esto, ya que no encuentro el como hacerlo.

 

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

@Syndicate_Admin ,

Creé algunos datos:

vyangliumsft_0-1643256458593.png

Puede usar pestañas para mostrar:

Estos son los pasos que puede seguir:

1. Crear medida.

VALOR_INICIAL_TOP_N_ORIG =
var _Table=SUMMARIZE(ALL('Table'),'Table'[Product],"Total",SUM('Table'[Value]))
var _TOP_TABLA=TOPN(3,_Table,[Total],DESC)
return
IF(
    MAX('Table'[Product]) in SELECTCOLUMNS(_TOP_TABLA,"1",[Product]),
    1,0)

2. Coloque [VALOR_INICIAL_TOP_N_ORIG]en Filtros, establezca is=1, aplique el filtro.

vyangliumsft_1-1643256458596.png

3. Resultado:

vyangliumsft_2-1643256458597.png

Saludos

Liu Yang

Si esta publicación ayuda,entonces considere Aceptarla como la solución para ayudar a los otros miembros a encontrarla más rápidamente

View solution in original post

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

@Syndicate_Admin ,

Creé algunos datos:

vyangliumsft_0-1643256458593.png

Puede usar pestañas para mostrar:

Estos son los pasos que puede seguir:

1. Crear medida.

VALOR_INICIAL_TOP_N_ORIG =
var _Table=SUMMARIZE(ALL('Table'),'Table'[Product],"Total",SUM('Table'[Value]))
var _TOP_TABLA=TOPN(3,_Table,[Total],DESC)
return
IF(
    MAX('Table'[Product]) in SELECTCOLUMNS(_TOP_TABLA,"1",[Product]),
    1,0)

2. Coloque [VALOR_INICIAL_TOP_N_ORIG]en Filtros, establezca is=1, aplique el filtro.

vyangliumsft_1-1643256458596.png

3. Resultado:

vyangliumsft_2-1643256458597.png

Saludos

Liu Yang

Si esta publicación ayuda,entonces considere Aceptarla como la solución para ayudar a los otros miembros a encontrarla más rápidamente

Syndicate_Admin
Administrator
Administrator

@Syndicate_Admin , Prueba como

Asumir valor en medida , Pruebe como

Medida =
var _tab = TOPN(3,allselected(table[Product]),[#VALOR_HECHOS_INICIAL],Desc)
devolución
calculate([Valor], filter(table, table[#VALOR_HECHOS_INICIAL] en _tab))

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.