Forum Discussion
Stock cumulative total DAX
Hi AGo,
I think i got your expectation. As my understand, you want to show comparison the initial inventory with cummulative of sale quantity (available stocks).
- Create Dates table :
Dates = CALENDARAUTO()
- Create Year column for fact(sales data) table:
Year = YEAR(data[Date])
- Now i created calculated column to show Initial Inventory for all rows:
Init inventory = CALCULATE(sum(data[Quantity]),FILTER(data,data[Initial Inventory]="Y" && data[ProductId]=EARLIER(data[ProductId]) && data[Year]=EARLIER(data[Year]) ))
- Create cummulative measure:
Cumm = CALCULATE(sum(data[Quantity]),filter(all(Dates), Dates[Date] <= MAX(Dates[Date]) && Dates[Date].[Year] = max(Dates[Date].[Year]) ))
(The cummulative has condition: Year= max(year) to ensure cummulative happens for each year as Time Pattern in topic: http://www.daxpatterns.com/time-patterns/)
Please notice that i use Date column of Dates table in showing fields.
Sample: https://www.dropbox.com/s/d07if69oxy7kuqw/Initial_Cummulative.pbix?dl=0
Data: https://www.dropbox.com/s/beqdng6ix8ws89e/InitialInventory_Cummulative.xlsx?dl=0
If this works for you please accept it as solution and also like to give KUDOS.
Best regards
Tri Nguyen
Hi tringuyenminh92,
I'm sorry but it's not working yet, the result is like a mere copy of the quantity column.
Hope to reach a solution.
- tringuyenminh929 years ago
Memorable Member
Hi AGo,
Please make relationship for date column of your fact table and Dates table, and check your formula in Cumm measure cause I saw something wrong in your formula.- AGo9 years ago
Post Patron
Hi tringuyenminh92,
I added the relationship but the result is the same: it's like a copy of quantity and it has a result only for the last year.
- tringuyenminh929 years ago
Memorable Member
Hi Anonymous, ImkeF, we need your help in this case cause i'm confusing and have no solution so far.