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

DAX/Formula AYUDA!

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!!

MesBEG INVAdicionalEND INVInventario final previsto
1100100200200
2200100300300
330050350350
4350200550550
555050600600
6 100 700
7 200 900
8 100 1000
9 100 1100
10 50 1150
11 100 1250
12 50 1300



7 REPLIES 7
caochs
Regular Visitor

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]
    )
Anonymous
Not applicable

@caochs gracias!!! Muy útil.

parry2k
Super User
Super User

@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.

Anonymous
Not applicable

@parry2k gracias por la respuesta. Creo que esto está en la dirección correcta, sin embargo, mis resultados fueron los siguientes:

MesBEG INVAdicionalEND INVInventario final previstoPARRY2K FORMULA
1100100200200200
2200100300300500
330050350350850
43502005505501400
5550506006002000
6 100 7002100
7 200 9002300
8 100 10002400
9 100 11002500
10 50 11502550
11 100 12502650
12 50 13002700

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

Capture.PNG

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:

Capture.PNGCapture1.PNG



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



@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.

Anonymous
Not applicable

Impresionante - muchas gracias!

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.