Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
Lo siento por el tema vago - No estoy seguro de cómo categorizar esto. Estoy tratando de predecir el inventario para el resto del año. Actualmente tengo datos de inventario final para los meses 1 a 5. Para calcular el inventario previsto para el resto del año, necesito tomar el inventario final del mes anterior y agregar el adicional. Sin embargo, esto sólo funciona una vez. Después de eso, tendría que auto-hacer referencia a la medida de inventario final predicha, pero esto causa una referencia circular. Entonces, ¿cómo realizo este cálculo? ¡¡Gracias!!
Mes | BEG INV | Adicional | END INV | Inventario final previsto |
1 | 100 | 100 | 200 | 200 |
2 | 200 | 100 | 300 | 300 |
3 | 300 | 50 | 350 | 350 |
4 | 350 | 200 | 550 | 550 |
5 | 550 | 50 | 600 | 600 |
6 | 100 | 700 | ||
7 | 200 | 900 | ||
8 | 100 | 1000 | ||
9 | 100 | 1100 | ||
10 | 50 | 1150 | ||
11 | 100 | 1250 | ||
12 | 50 | 1300 |
Hola @paquetteth - Veo que ya marcó la solución, pero pensé en compartir esta medida con usted de cualquier manera. Avísame si tienes alguna pregunta:
Predicted Ending Inv =
//Find the last month with an ending inventory for use later
VAR maxEndInvMonth =
CALCULATE (
MIN ( 'Table'[MONTH] ),
FILTER ( ALL ( 'Table' ), ISBLANK ( 'Table'[END INV] ) )
)
RETURN
SUMX (
ADDCOLUMNS (
SUMMARIZE (
'Table',
'Table'[MONTH],
'Table'[END INV],
//Start the running total once there is no longer an ending inventory
"RunningAdditionalNoEndingInventory", CALCULATE (
SUM ( 'Table'[ADDITIONAL] ),
FILTER (
ALL ( 'Table' ),
'Table'[MONTH] <= MAX ( 'Table'[MONTH] )
&& 'Table'[MONTH] >= maxEndInvMonth
)
)
),
//This column is for demonstration purposes only and is not needed for the calculation
"EarlierEndInv", CALCULATE (
MAX ( 'Table'[END INV] ),
FILTER ( 'table', 'table'[MONTH] < EARLIER ( 'table'[MONTH], 1 ) )
),
//Check if the month has an ending inventory, if it does not then use the running total plus the "EARLIER" ending inventory. If it has an ending inventory use that instead.
"PredictedEndingInv", IF (
CALCULATE ( MAX ( 'Table'[MONTH] ) ) >= maxEndInvMonth,
CALCULATE (
MAX ( 'Table'[END INV] ),
FILTER ( ALL ( 'table' ), 'table'[MONTH] < EARLIER ( 'table'[MONTH], 1 ) )
) + [RunningAdditionalNoEndingInventory],
'Table'[END INV]
)
),
[PredictedEndingInv]
)
@paquetteth usted está buscando en total
Predicted Ending Inventory =
CALCULATE (
SUM ( Table[Beg Inv] ) +
SUM ( Table[Additionaol ),
FILTER (
ALL ( Table ),
Table[Month] <= MAX ( Table[Month] )
)
Me gustaría❤ elogiossi mi solución ayudara.👉Si puedes pasar tiempo publicando la pregunta, también puedes hacer esfuerzos para dar a Kudos quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!
⚡Visítenos enhttps://perytus.com, su ventanilla única para proyectos/formación/consulta relacionados con Power BI.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k gracias por la respuesta. Creo que esto está en la dirección correcta, sin embargo, mis resultados fueron los siguientes:
Mes | BEG INV | Adicional | END INV | Inventario final previsto | PARRY2K FORMULA |
1 | 100 | 100 | 200 | 200 | 200 |
2 | 200 | 100 | 300 | 300 | 500 |
3 | 300 | 50 | 350 | 350 | 850 |
4 | 350 | 200 | 550 | 550 | 1400 |
5 | 550 | 50 | 600 | 600 | 2000 |
6 | 100 | 700 | 2100 | ||
7 | 200 | 900 | 2300 | ||
8 | 100 | 1000 | 2400 | ||
9 | 100 | 1100 | 2500 | ||
10 | 50 | 1150 | 2550 | ||
11 | 100 | 1250 | 2650 | ||
12 | 50 | 1300 | 2700 |
Hola @paquetteth ,
Cree una nueva consulta en blanco y pegue este mcode para crear una función recursiva:
(_table como tabla, _month como número, _currentMonth como número, _inventoryValue como número) como número >
Dejar
Origen: Table.SelectRows(_table, cada [MONTH] á _month),
BEG_INV si Source[BEG INV]{0} ? null o _month > 1 entonces 0 else Source[BEG INV]{0},
ADICIONAL - si Source[ADDITIONAL]{0} - null entonces 0 else Source[ADDITIONAL]{0},
PredictValue - _inventoryValue + ADICIONAL + BEG_INV,
Resultado: si _month < _currentMonth, @FN_PredictValues(_table, _month + 1, _currentMonth, PredictValue) de otro lugar PredictValue)
En
Resultado
Utilice este mcode para crear la tabla base:
Dejar
Source: Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bcxBCsAgDATAr0jOOSSxse1bxP9/Q7GrSMllWYZNaiUlJhXZaSMbVzL05RmeZl8sn98oa8jhzs65gVfyuhp/07Tbpgd9gS7NzAVoB+m0dB+w9YB", BinaryEncoding.Base64), Compression.Deflate)), deje _t ((tipo de texto que acepta valores NULL) meta [Serialized.Text ? true]) en la tabla de tipos [MONTH - _t, "BEG INV" - _t, ADICIONAL a _t, "END INV" - _t]),
"Tipo cambiado" - Table.TransformColumnTypes(Source,"MONTH", Int64.Type, "BEG INV", Int64.Type, "ADDITIONAL", Int64.Type, "END INV", Int64.Type),
"Añadido Personalizado" - Table.AddColumn(-"Changed Type", "Custom", cada fn_PredictValues("Changed Type", 1, [MONTH], 0))
En
"Añadido personalizado"
o crear una columna personalizada como esta:
@paquetteth probar esta medida
Measure 3 =
SUMX (
FILTER ( ALL ( Bal[MONTH] ), Bal[MONTH] <= MAX ( Bal[MONTH] ) ),
CALCULATE ( SUM ( Bal[ADDITIONAL] ) )
)
+ CALCULATE ( SUM ( Bal[BEG INV] ), Bal[MONTH] = 1 )
Me gustaría❤ elogiossi mi solución ayudara.👉Si puedes pasar tiempo publicando la pregunta, también puedes hacer esfuerzos para dar a Kudos quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!
⚡Visítenos enhttps://perytus.com, su ventanilla única para proyectos/formación/consulta relacionados con Power BI.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Impresionante - muchas gracias!
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.