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

Calcular fecha al ejecutar El objetivo de aciertos totales

Hola comunidad,

Soy bastante nuevo en Power BI y Dax y bastante frustrado porque no soy capaz de resolver este problema incluso después de horas de googeling (encontré publicaciones en el foro (por ejemplo, aquí y aquí ) que estaban relacionados con mi problema, pero no pude aplicar las soluciones). Le agradecería mucho su ayuda.

Escenario:
Quiero predecir el desarrollo de mi inventario. Sé cuántos artículos están en stock en este momento y sé cuándo se retirará una cantidad específica de un producto específico.

Mi objetivo:

Quiero saber en qué día el inventario de un producto dado caerá por debajo de cero. Por lo tanto, quiero crear una columna calculada (o una medida, me dice) para la tabla de dimensiones de producto donde se muestra esta fecha.

Datos de prueba:

He creado una prueba pbix (Enlace) para mostrar mi problema.

Relaciones:

dim Date 1 -- * Fact Transactions * -- 1 dim Products

Creé una medida total/cummulativa usando la fórmula estándar:

Cantidad acumulada ?
CALCULAR (
SUM ( 'Fact Future Transactions'[Cantidad]);
FILTRO (
ALL ( 'Dim Date'[Fecha] );
'Dim Date'[Fecha] <- MAX ( 'Dim Date'[Date] )
)
)

La tabla de transacciones tiene este aspecto. Los números positivos representan la acción actual (hoy es el 3 de junio) mientras que los números negativos a continuación representan retiros futuros.

FechaCantidadProducto
03.06.202010A
03.06.202010B
04.06.2020-2A
05.06.2020-2B
06.06.2020-2A
07.06.2020-3B
08.06.2020-3A
09.06.2020-3B
10.06.2020-3A
11.06.2020-4B
12.06.2020-4A

Y el resultado que quiero ver en mi tabla de productos Dim se ve así:

ID de productoSe agota
A10.06.2020
B11.06.2020

Agradezco la ayuda. Gracias de antemano.

Lucas

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@lucasnebot pruebe la siguiente medida:

Stock Run Out Date = 
VAR __date = CALCULATETABLE( FILTER( ALL ( 'Dim Date'[Date] ), 'Dim Date'[Date] <= MAX ( 'Dim Date'[Date] ) ) ) 
VAR __data = 
SUMMARIZE ( 
    CROSSJOIN ( 
        VALUES ( 'Dim Products'[Product ID] ),
        __date 
    ),
    'Dim Products'[Product ID], 
    'Dim Date'[Date], 
    "__cumulative Quantity",  [Cumulative Quantity],
    "__cumulative Is Blank",  [Cumulative Quantity] ==BLANK() 
) 
RETURN

MINX ( 
    FILTER (
        __data,
        [__cumulative Quantity] <=0 && 
        NOT [__cumulative Is Blank]
    ), 
    [Date] 
)

Y aquí está la salida


image.png

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.

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@lucasnebot pruebe la siguiente medida:

Stock Run Out Date = 
VAR __date = CALCULATETABLE( FILTER( ALL ( 'Dim Date'[Date] ), 'Dim Date'[Date] <= MAX ( 'Dim Date'[Date] ) ) ) 
VAR __data = 
SUMMARIZE ( 
    CROSSJOIN ( 
        VALUES ( 'Dim Products'[Product ID] ),
        __date 
    ),
    'Dim Products'[Product ID], 
    'Dim Date'[Date], 
    "__cumulative Quantity",  [Cumulative Quantity],
    "__cumulative Is Blank",  [Cumulative Quantity] ==BLANK() 
) 
RETURN

MINX ( 
    FILTER (
        __data,
        [__cumulative Quantity] <=0 && 
        NOT [__cumulative Is Blank]
    ), 
    [Date] 
)

Y aquí está la salida


image.png

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

Gracias @parry2k . Esa medida hizo el truco. Permítanme hacer una pregunta de seguimiento: ¿Cuáles son las ventajas de usar una medida en lugar de una columna calculada aquí?

@lucasnebot gran pregunta. leer este post

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.

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.