Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Syndicate_Admin
Administrator
Administrator

Explosión de BOM dentro de BOM

Hola, por favor necesito ayuda en la siguiente situación:

Tengo 3 tablas:

SalesOrderTable

OrdenNumProductoCantidad
ON-01P110
ON-01P220
ON-01P330
ON-02P120
ON-02P215

Tabla de productos

ProductoCategoría
P1Producto terminado
P2Producto terminado
P3Producto terminado
RM1Materia prima
RM2Materia prima
RM3Materia prima

BillsOfMaterialTable

Producto terminadoMateria primaPorcentaje%
P1RM10,33
P1RM20,33
P1P20,33
P2RM20,5
P2RM30,5

Necesito explotar la fórmula BOM con productos SalesOrderTable para medir las cantidades de producto terminado y materia prima, pero si miramos más allá, dentro de P1 tenemos otro producto terminado llamado P2, que necesita explosión para obtener cantidades de RM también, creando otra iteración, y así sucesivamente....

No es tan difícil cuando solo tenemos una iteración, pero a medida que avanzamos con más de una, se complica y consume memoria ...

Entonces, ¿cuál sería la mejor manera de calcular todas las iteraciones sin crear tantas condiciones y columnas para tener todas las cantidades de productos terminados y materias primas?

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

Si desea utilizar una función recursiva de Power Query M, tengo una función de lista de materiales aquí con explosiones ilimitadas.

https://github.com/edouardbrasier/Recursion-example-bill-of-materials

Syndicate_Admin
Administrator
Administrator

@aferreira_adm ,

Estos son los pasos que puede seguir:

1. Crear medida.

Finished Products quantities =
var _select=SELECTEDVALUE('SalesOrderTable'[Product])
var _sumquantity=SUMX(FILTER(ALL(SalesOrderTable),'SalesOrderTable'[Product]=_select),[Quantity])
var _p1=MAXX(FILTER(ALL('Product Category'),'Product Category'[Product]=_select),[Category])
var _column=SELECTCOLUMNS(FILTER(ALL('Product Category'),'Product Category'[Category]=_p1),"1",[Product])
return
IF(
    MAX('BillsOfMaterialTable'[FinishedProduct]) in _column&&MAX('BillsOfMaterialTable'[FinishedProduct])=_select,_sumquantity *MAX('BillsOfMaterialTable'[Percentage%]),0)
Raw Materials =
var _select=SELECTEDVALUE('SalesOrderTable'[Product])
var _sumquantity=SUMX(FILTER(ALL(SalesOrderTable),'SalesOrderTable'[Product]=_select),[Quantity])
var _p1=MAXX(FILTER(ALL('Product Category'),'Product Category'[Product]=_select),[Category])
var _column=SELECTCOLUMNS(FILTER(ALL('Product Category'),'Product Category'[Category]=_p1),"1",[Product])
return
IF(
    NOT(MAX('BillsOfMaterialTable'[RawMaterial]))in _column&&MAX('BillsOfMaterialTable'[FinishedProduct])=_select,_sumquantity *MAX('BillsOfMaterialTable'[Percentage%]),0)

2. Resultado:

vyangliumsft_0-1666750403627.png

Si los resultados no cumplen con sus expectativas, puede mostrar los resultados esperados en forma de imágenes, cómo obtener cantidades de productos terminados y materias primas, podemos ayudarlo mejor

Saludos

Liu Yang

Si esta publicación ayuda, considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.