Forum Discussion
Data Model Retail Business (help!!)
Hi Anonymous,
Ok so probably not the most elegant Solution, but given that you are looking to infer dimension values I created 3 Columns for you in the F_Stock Table
Coverage Days =
var val = DIVIDE('F_Stock'[Stock Value], 'F_Stock'[Sales Value])*30
return
if(val = 0, 0, val)
Coverage Label =
SWITCH(
TRUE(),
'F_Stock'[Coverage Days] = 0, "No Sales",
'F_Stock'[Coverage Days] < 20, "Less than 20 Days",
'F_Stock'[Coverage Days] < 50, "Less than 50 Days",
"More than 50 Days"
)
//to be used as the sort by column for Coverage Label
Coverage Index =
SWITCH(
TRUE(),
[Coverage Days] =0, 4,
[Coverage Days] <= 20, 1,
[Coverage Days] <= 50, 2,
[Coverage Days] > 49, 3
)
You can then create a matrix like the following
You can also create the calc columns in Power Query by join the stock and sales tables together or adjust your source queries to get the stock and sales in the same table. but for now this seems to do the trick
hope this helps,
Richard
Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!
Hi Richard,
Thans for the reply. The table looks superb,
Is it possible to share the model? Im still very beginner so its dificult to me to understand the explantion just based on code.
Thanks!
- richbenmintz6 years agoResident Rockstar
Hi Anonymous,
Sure thing, link here, link to pbix.
In words essentially what i created where three calculated columns in the F_Stock Table
[Coverage Days] = stock / sales *30
[Coverage Label] = Case statement to assign correct label based on [Coverage Days] Value
[Coverage Index] = Case statement to assign correct order for [Coverage Label] based on [Coverage Days] Value This value is used as the sort by value for the [Coverage Label] Column
Once the Calculated Columns are available you can create the matrix you are looking for
- Anonymous6 years agoNot applicable
richbenmintz Uau this looks amazing!!
In onder to understand better the solution:
Is is possible to explain why did you make the [coverage days_], [coverage index_] and [coverage label_] also on the "F_sales"? Any reason or this is not used? From my understanding it seems not to be used by the model.
At the same time, it would be feasible to add to more columsn on the F_Stock with sales of "month n-1" and "month n-"2? And at the same time to adapt the coverage days formula from "stock / sales" to "stock / average sales (month n, n-1,n-2)" (i make a picture - below - in order to facilitate what im triying to say)
If i get your logical, i can adapt it to my reality.
Again and again...all my respect and thanks for your extraordinary help!
André
- richbenmintz6 years agoResident Rockstar
Hi Anonymous,
The Columns in the F_Sales sales table are not really relevent, just a product of initial tests.
I will review the Month - N ask in a little while.
Thanks