Forum Discussion
Data Model Retail Business (help!!)
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é
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
- richbenmintz6 years agoResident Rockstar
Hi Anonymous,
I mocked up a disconnected dimension approach to make the stock value by day inventory a little more dynamic which will allow you to perform date look backs a little more on the fly without having to create columns for each permutation.
Solution as follows:
Disconnected Dimension - Create Dax Calc Table:
Coverage = DATATABLE( "Coverage", STRING, "Coverage Index", INTEGER, { {"More than 50 Days", 3}, {"No Sales", 4}, {"Less than 20 Days", 1}, {"More than 20 Days", 2} } )Current Period Measure:
stock Value Dynamic CP = var tbl = ADDCOLUMNS('F_Stock',"coverage", divide([Stock value], [Sales value], 0)*30, "visible", switch(true(), [Sales value] = BLANK() && min(Coverage[Coverage Label]) = "No Sales", [Stock value], [Sales value] > 0 && divide([Stock value], [Sales value])*30 < 20 && min(Coverage[Coverage Label]) = "Less than 20 Days", [Stock value], [Sales value] <> 0 && divide([Stock value], [Sales value])*30 >=20 && divide([Stock value], [Sales value])*30 < 50 && min(Coverage[Coverage Label]) = "Less than 50 Days", [Stock value], [Sales value] > 0 && divide([Stock value], [Sales value])*30 >= 50 && min(Coverage[Coverage Label]) = "More than 50 Days", [Stock value] )) var ret = if(HASONEVALUE(Coverage[Coverage Label]), CALCULATE(SUMX(tbl, [visible])), sum([Stock value])) return retCurrent Period Measure Prior Period:
stock Value Dynamic CP = var tbl = ADDCOLUMNS('F_Stock',"coverage", divide([Stock value], [Sales value], 0)*30, "visible", switch(true(), [Sales value] = BLANK() && min(Coverage[Coverage Label]) = "No Sales", [Stock value], [Sales value] > 0 && divide([Stock value], [Sales value])*30 < 20 && min(Coverage[Coverage Label]) = "Less than 20 Days", [Stock value], [Sales value] <> 0 && divide([Stock value], [Sales value])*30 >=20 && divide([Stock value], [Sales value])*30 < 50 && min(Coverage[Coverage Label]) = "Less than 50 Days", [Stock value], [Sales value] > 0 && divide([Stock value], [Sales value])*30 >= 50 && min(Coverage[Coverage Label]) = "More than 50 Days", [Stock value] )) var ret = if(HASONEVALUE(Coverage[Coverage Label]), CALCULATE(SUMX(tbl, [visible])), sum([Stock value])) return retCouple Caveats:
- Date Math is not very robust just subtracts one from the Max Month in context
- Better to have a YearMonth column in the date table like, 202010, then subtracting 100 will always return the prior month
- Assumes that Month will be in the context as it uses Max to get current month and then subtracts 1, may be better to check to see if Month has a single value and then perform the calc else return blank()
I all new formulas saved to shared pbix
Hope this helps you out,
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! - Anonymous6 years agoNot applicable
Hi,
Thanks for the input!
I will test it and then came to give feedback.
Cheers and thank you again
- Anonymous6 years agoNot applicable
Hi richbenmintz
The solution is working perfectly!
I was trying on the final model to show only in percentages. I donne it but know i found an error.
For example, in the month 11, Paris Store. Yellow highlighted.
I was trying to just show the "More than 50 days" and the "No sales" on the table below and, at the same time, the percentages of these two "labels", according with TOTAL stock of the store (and not just the ones i selected "more than 50 days" and the "no sales").
However, when i select the "no sales" and the "more than 50 days" i have a % of 100% for the total of the store. However the righ percentage should be 128 / 179 = 71,5% and not 128 /128 = 100%. I hope i make myself clear on these explanation. Is there any chance to bypass this?
Cheers!
- richbenmintz6 years agoResident Rockstar
Hi Anonymous,
Can you provide the measure you created? will be easier for me to understand what needs to be changed.
Thanks,