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

Niveles de inventario actuales

Necesito averiguar una medida que calcule el nivel de inventario actual en función de la última entrada de inventario de artículos en la tabla. A continuación se muestra un ejemplo de 5 artículos y a la derecha marqué la última fecha de inventario de cada artículo. La suma del inventario de 5 artículos del último día en que se inventariaron es de 12. El resultado de la medida debe ser 12.

Curr Inventory Example Image.png

2 ACCEPTED SOLUTIONS

Bingo @ReynoldsTstan16, eso es genial. Hice el truco. Definitivamente algunos errores de sintaxis y me perdí un EARLIER. PBIX está unido.

 VAR __Table =
    ADDCOLUMNS(
      GROUPBY(
        'Table',
        [Item],
        "__LastDate",MAXX(CURRENTGROUP(),[Date])
      ),
      "__LastInventory",MAXX(FILTER('Table','Table'[Date] = [__LastDate] && 'Table'[Item] = EARLIER([Item])),'Table'[Qty])
    )
RETURN
  SUMX(__Table,[__LastInventory])


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Hola

La respuesta debe ser 13 (no 12). Puede descargar mi archivo PBI desde aquí.

Espero que esto ayude.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

10 REPLIES 10
Greg_Deckler
Super User
Super User

Bueno, no hay datos de muestra publicados como texto por lo que este DAX probablemente tendrá algunos errores de sintaxis en él, pero estoy suuuuupppper aburrido porque todo se apaga con estas cosas COVID-19 pasando. Además me di cuenta de que este es un poco de un patrón diferente, aunque todavía podría haber utilizado ese patrón. Pero algo como esto podría ser mejor:

Current Inventory Measure = 
  VAR __Table =
    ADDCOLUMNS(
      SUMMARIZE(
        'Table',
        [Item 1],
        "__LastDate",MAX([Date])
      ),
      "__LastInventory",MAXX(FILTER('Table','Table'[Date] = [__LastDate] && 'Table'[Item 1] = [Item 1],'Table'[Qty])
    )
RETURN
  SUMX(__Table,[__LastInventory])

Ah, y los datos de muestra publicados como texto siempre son geniales. Por favor, consulte este post sobre cómo obtener su pregunta respondida rápidamente: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

¿Es útil para probar la fórmula?

FechaArtículoQty
3/2/2020Tema 11
3/20/2020Tema 12
3/19/2020Tema 24
2/28/2020Tema 21
3/1/2020Tema 31
1/16/2020Tema 40
2/21/2020Tema 44
3/19/2020Tema 43
12/6/2019Tema 52
2/10/2020Tema 52
3/21/2020Tema 53

Hola

La respuesta debe ser 13 (no 12). Puede descargar mi archivo PBI desde aquí.

Espero que esto ayude.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Tanto Ashish!!!

De nada.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Bingo @ReynoldsTstan16, eso es genial. Hice el truco. Definitivamente algunos errores de sintaxis y me perdí un EARLIER. PBIX está unido.

 VAR __Table =
    ADDCOLUMNS(
      GROUPBY(
        'Table',
        [Item],
        "__LastDate",MAXX(CURRENTGROUP(),[Date])
      ),
      "__LastInventory",MAXX(FILTER('Table','Table'[Date] = [__LastDate] && 'Table'[Item] = EARLIER([Item])),'Table'[Qty])
    )
RETURN
  SUMX(__Table,[__LastInventory])


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hola @GR ,

Gracias por su solución. Una pregunta adicional: ¿cómo necesita modificar la sintaxis si el conjunto de datos tiene la mutación para cada elemento: en otras palabras, en el ejemplo de ReynoldTstan, para el elemento 4 desea mostrar el número acumulativo (0+4+3-7) en lugar del último (3)?

Muchas gracias por su ayuda por adelantado!

Anonymous
Not applicable

Hola @GR ,

Gracias por su solución. Una pregunta adicional: ¿cómo necesita modificar la sintaxis si el conjunto de datos tiene la mutación para cada elemento: en otras palabras, en el ejemplo de ReynoldTstan, para el elemento 4 desea mostrar el número acumulativo (0+4+3-7) en lugar del último (3)?

Muchas gracias por su ayuda por adelantado!

Anonymous
Not applicable

Impresionante... thx Greg!!!

Greg_Deckler
Super User
Super User

¡Ja! Literalmente acabo de escribir esta medida rápida hoy. ¡Es la primera vez que lo uso! 🙂

https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/td-p/985814

Ese es el patrón, tendrás que adaptarlo un poco. Avísame si necesitas más ayuda para adaptarlo.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.