Forum Discussion
Tertiary Sales - Retail
- 5 years ago
Hi morab ,
As the data you provided at the first time didnt contain different Outlet code,Outlet and SKU in Sales table and stock table,I didnt consider about the difference,that's the reason why you saw the error.Modify the measure as below:
By Date Tertirary Sales = var _OpeningStockoftheday=CALCULATE(SUM('Stock Survey Report1'[Pcs]),FILTER('Stock Survey Report1','Stock Survey Report1'[Date]=SELECTEDVALUE('Calendar'[Date])&&'Stock Survey Report1'[Outlet Code]=MAX('Stock Survey Report1'[Outlet Code])&&'Stock Survey Report1'[Outlet]=MAX('Stock Survey Report1'[Outlet])&&'Stock Survey Report1'[SKU]=MAX('Stock Survey Report1'[SKU]))) var _Salesoftheday=CALCULATE(SUM('Sales Report'[Pcs]),FILTER(ALL('Sales Report'),'Sales Report'[Date]=SELECTEDVALUE('Calendar'[Date])&&'Sales Report'[Outlet Code]=MAX('Stock Survey Report1'[Outlet Code])&&'Sales Report'[Outlet]=MAX('Stock Survey Report1'[Outlet])&&'Sales Report'[SKU]=MAX('Stock Survey Report1'[SKU]))) var _ClosingStockoftheday=CALCULATE(SUM('Stock Survey Report1'[Pcs]),FILTER(ALL('Stock Survey Report1'),'Stock Survey Report1'[Date]=SELECTEDVALUE('Calendar'[Date])+1&&'Stock Survey Report1'[Outlet Code]=MAX('Stock Survey Report1'[Outlet Code])&&'Stock Survey Report1'[Outlet]=MAX('Stock Survey Report1'[Outlet])&&'Stock Survey Report1'[SKU]=MAX('Stock Survey Report1'[SKU]))) Return _OpeningStockoftheday+_Salesoftheday-_ClosingStockofthedayAnd you will see:
In the measure above,you need to identify the Outlet code,Outlet and SKU where I use such as
'Sales Report'[Outlet Code]=MAX('Stock Survey Report1'[Outlet Code])&&'Sales Report'[Outlet]=MAX('Stock Survey Report1'[Outlet])&&'Sales Report'[SKU]=MAX('Stock Survey Report1'[SKU])to make sure that the calculation would be excuted with the correct data.
For the updated .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
Hi v-kelly-msft
Sorry for the delay in response.
When I add few more data in the both data table only chanaging the outlet code, outlet name & SKU, its showing following:
Can you please guide me to get the desire result?
Best Regards
Hi morab ,
As the data you provided at the first time didnt contain different Outlet code,Outlet and SKU in Sales table and stock table,I didnt consider about the difference,that's the reason why you saw the error.Modify the measure as below:
By Date Tertirary Sales =
var _OpeningStockoftheday=CALCULATE(SUM('Stock Survey Report1'[Pcs]),FILTER('Stock Survey Report1','Stock Survey Report1'[Date]=SELECTEDVALUE('Calendar'[Date])&&'Stock Survey Report1'[Outlet Code]=MAX('Stock Survey Report1'[Outlet Code])&&'Stock Survey Report1'[Outlet]=MAX('Stock Survey Report1'[Outlet])&&'Stock Survey Report1'[SKU]=MAX('Stock Survey Report1'[SKU])))
var _Salesoftheday=CALCULATE(SUM('Sales Report'[Pcs]),FILTER(ALL('Sales Report'),'Sales Report'[Date]=SELECTEDVALUE('Calendar'[Date])&&'Sales Report'[Outlet Code]=MAX('Stock Survey Report1'[Outlet Code])&&'Sales Report'[Outlet]=MAX('Stock Survey Report1'[Outlet])&&'Sales Report'[SKU]=MAX('Stock Survey Report1'[SKU])))
var _ClosingStockoftheday=CALCULATE(SUM('Stock Survey Report1'[Pcs]),FILTER(ALL('Stock Survey Report1'),'Stock Survey Report1'[Date]=SELECTEDVALUE('Calendar'[Date])+1&&'Stock Survey Report1'[Outlet Code]=MAX('Stock Survey Report1'[Outlet Code])&&'Stock Survey Report1'[Outlet]=MAX('Stock Survey Report1'[Outlet])&&'Stock Survey Report1'[SKU]=MAX('Stock Survey Report1'[SKU])))
Return
_OpeningStockoftheday+_Salesoftheday-_ClosingStockoftheday
And you will see:
In the measure above,you need to identify the Outlet code,Outlet and SKU where I use such as
'Sales Report'[Outlet Code]=MAX('Stock Survey Report1'[Outlet Code])&&'Sales Report'[Outlet]=MAX('Stock Survey Report1'[Outlet])&&'Sales Report'[SKU]=MAX('Stock Survey Report1'[SKU])
to make sure that the calculation would be excuted with the correct data.
For the updated .pbix file,pls see attached.
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!