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.
Hola
He alcanzado un bloqueo de carretera y busco ayuda en el cálculo de la media ponderada para los siguientes datos.
El riesgo de columna2 determina qué productos están en una categoría de riesgo y se calcula de la siguiente manera
Risk2 = if(([Consumption]) > [Forecast],0,1)
Sospecho que hay una mejor manera de calcular la relación de elementos "Riesgo" para cada subcategoría (A-C). Intenté usar ALLSELECTED[GROUP] pero alguna razón por la que no funcionó. Aquí está la medida calculada que usé
% = DIVIDE(sum([Risk2]), calculate(COUNT([Risk2]),ALLSELECTED([ITEMCODE])))
Y luego el resultado final que estoy tratando de lograr es el promedio ponderado
El Grupo A tiene un 50% de weght,
Grupo B - 30%
Grupo C - 20%
y los grupos restantes (D-F) son 0%.
Necesito obtener la suma de % de cada grupo multiplicado por peso - 60*0.5 + 93.75*0.3 + 80*0.2 á 74.25
La medida actual es una simple declaración IF, pero eso no parece funcionar
Weighted % =
VAR FR =
DIVIDE(sum([Risk2]), calculate(COUNT([Risk2]),ALLSELECTED([ITEMCODE])))
RETURN
IF(MAX([GROUP] )= "A",FR * 0.5,
IF (MAX([GROUP]) = "B", FR * 0.3,
IF( MAX([GROUP]) = "C", FR * 0.2,
IF( MAX([GROUP]) = "D", FR * 0,
IF( MAX([GROUP]) = "E", FR * 0,
IF( MAX([GROUP]) = "F", FR * 0,FR * 0
))))))
Gracias
Solved! Go to Solution.
Debe proporcionar un contexto de fila para que esto funcione cuando hay más de un grupo seleccionado.
Intente usar:
Weighted % =
VAR FR =
DIVIDE(sum([Risk2]), calculate(COUNT([Risk2]),ALLSELECTED([ITEMCODE])))
RETURN
SUMX(VALUES([GROUP]),
SWITCH([Group]
, "A",FR * 0.5
, "B", FR * 0.3
, "C", FR * 0.2
, "D", FR * 0
, "E", FR * 0
,"F", FR * 0
,FR * 0
)
)
Además, es probable que pueda utilizar la función AVERAGE en lugar de DIVIDE, SUM y COUNT.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
@rigosakhx Eso se ve bonito y elegante. Bien hecho, y de nada. 🙂
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Actualización - según AllisonKennedy reemplazó DIVIDE SUM COUNT con AVERAGE y creó una medida separada para él.
% - AVG[Riesgo2]
Entonces no necesitaba usar VAR en mi medida final
% ponderado ?
SUMX(VALUES([GROUP]),
SWITCH([Grupo]
, "A",AVG * 0,5
, "B", AVG * 0,3
, "C", AVG * 0,2
,AVG* 0
))
El código tiene más sentido y funciona según lo previsto
Muchas gracias a AllisonKennedy
Hola @AllisonKennedy
Gracias por esto
Casi funcionó - pero por alguna razón la suma es igual a la relación no ponderada
Debe proporcionar un contexto de fila para que esto funcione cuando hay más de un grupo seleccionado.
Intente usar:
Weighted % =
VAR FR =
DIVIDE(sum([Risk2]), calculate(COUNT([Risk2]),ALLSELECTED([ITEMCODE])))
RETURN
SUMX(VALUES([GROUP]),
SWITCH([Group]
, "A",FR * 0.5
, "B", FR * 0.3
, "C", FR * 0.2
, "D", FR * 0
, "E", FR * 0
,"F", FR * 0
,FR * 0
)
)
Además, es probable que pueda utilizar la función AVERAGE en lugar de DIVIDE, SUM y COUNT.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |