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

Cumulative Inventory Sum Measure

Hi all, I have looked high and low on this forum, and can't find a solution for this.  I'm looking to create a cumulative sum by quantity of inventory quantities (the 'Quantity' field shown below) where there are Current Inventory, Sales Orders, Production Orders, Purchase Orders listed by item, date and site.  Inventory values are always shown with the current date, which I built in Power Query, but am willing to change if there is a better solution.  Here is an example - how do I create a measure that captures this?  Thanks in advance!

 

IDItemDateSiteTypeQuantity
Inventory10031629/10/2020GARD1Inventory12
301020966410031629/11/2020GARD1Sales Order-3
301020869010031629/4/2020IVYL1Sales Order-3
301020841410031629/4/2020IVYL1Sales Order-10
301020886510031629/8/2020IVYL1Sales Order-4
301020886510031629/8/2020IVYL1Sales Order-1
301020881810031629/8/2020IVYL1Sales Order-1
301020898710031629/9/2020IVYL1Sales Order-2
301020754010031629/9/2020IVYL1Sales Order-5
Inventory10031629/10/2020IVYL1Inventory994
301020921510031629/10/2020IVYL1Sales Order-1
301020838610031629/10/2020IVYL1Sales Order-14
301020939310031629/10/2020IVYL1Sales Order-1
301020971610031629/11/2020IVYL1Sales Order-1
301020994610031629/14/2020IVYL1Sales Order-2
301020994410031629/14/2020IVYL1Sales Order-4
301019945310031629/18/2020IVYL1Sales Order-133
301020687710031629/28/2020IVYL1Sales Order-1
301020687910031629/28/2020IVYL1Sales Order-1
301020576710031629/28/2020IVYL1Sales Order-1
301020576310031629/28/2020IVYL1Sales Order-1
Inventory10031629/10/2020WARM1Inventory0
10001698410031629/28/2020WARM1Production Orders1064
1 ACCEPTED SOLUTION

hi  @Anonymous 

You are missing ALL in your formula, just adjust it as below:

Cumm Sum =
CALCULATE (
    SUM ( Stock[Quantity] ),
    FILTER (
        ALL ( TableFiscalCalendar ),
        TableFiscalCalendar[GregorianDate] <= MAX ( TableFiscalCalendar[GregorianDate] )
    )
)

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , Create a date table and join it with your table and try a measure like

 

Cumm Sales = CALCULATE(SUM(Table[Quantity]),filter(date,date[date] <=maxx(date,date[date])))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

Anonymous
Not applicable

Hi @amitchandak , thanks for the response, however this measure not work.  I have the date table (TableFiscalCalendar) marked as a date table and there is a relationship between Table and TableFiscalCalendar using Table[Date] and TableFiscalCalendar[GregorianDate] fields.  

 

Cumm Sum = CALCULATE(SUM(Stock[Quantity]),filter(TableFiscalCalendar,TableFiscalCalendar[GregorianDate] <=maxx(TableFiscalCalendar,TableFiscalCalendar[GregorianDate])))
 
Should this be adjusted?

hi  @Anonymous 

You are missing ALL in your formula, just adjust it as below:

Cumm Sum =
CALCULATE (
    SUM ( Stock[Quantity] ),
    FILTER (
        ALL ( TableFiscalCalendar ),
        TableFiscalCalendar[GregorianDate] <= MAX ( TableFiscalCalendar[GregorianDate] )
    )
)

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

@Anonymous - Can you just use the Running Total Quick Measure built-in to Power BI Desktop?


@ 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

@Greg_Deckler, the running total quick measure has not worked - I've used this criteria and the field only brings in the same value for Quantity:

 

garynorcross_0-1599746859692.png

 

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.