Forum Discussion
manoranjan
7 years agoFrequent Visitor
Stock Cover Calculation Measure
Hi All, I have Weekly data of Stock and Planned Sales. For any given week, I want to Calculate the Stock Cover. Stock Cover = How many weeks of Sales I can cover with the Current Stock. My D...
- 7 years ago
You may check the following DAX.
Column = VAR s = Table1[Stock] VAR w = Table1[Week] VAR t = FILTER ( Table1, Table1[Week] > w ) VAR t2 = ADDCOLUMNS ( t, "total", SUMX ( FILTER ( t, Table1[Week] <= EARLIER ( Table1[Week] ) ), Table1[Sales Plan] ) ) RETURN IF ( COUNTROWS ( FILTER ( t2, [total] >= s ) ) > 0, COUNTROWS ( FILTER ( t2, [total] < s ) ) + DIVIDE ( s - MAXX ( TOPN ( 1, FILTER ( t2, [total] < s ), Table1[Week], DESC ), [total] ), MAXX ( TOPN ( 1, FILTER ( t2, [total] >= s ), Table1[Week], ASC ), Table1[Sales Plan] ) ) )
venug20
7 years agoResolver I
use below formula to achive..
Stock Cover = SUM(Weeks[Stock]) / SUM(Weeks[Sales Plan])
If it is solution to your query, Pls accept as solution...
manoranjan
7 years agoFrequent Visitor
Thanks for reply venug20
But what I want to achieve is different.
For example, my current week (week 1) Stock is 100 units.
Sales plan
W2 = 40,
W3=50,
W4=50
With the current stock of 100 units, I can sell upto 2.1 weeks forward.
Your solution takes care of only the Current Weeks sales. So this will not work in my scenario.