Forum Discussion
Tertiary Sales - Retail
Hi,
Good Day & Happy New Year 2021!!!
I have to calculate tertiary outlet sales by date & by cumulative;
Conditions:
By Date Tertirary Sales = Opening Stock of the day + Sales of the day - Closing Stock of the day;
For example:Tertirary Sales of 2-Jan-20 = 10 + 2 - 7 = 5;
By Cumulaive Tertiary Sales = Opening stock of specific date range + Sales of specific date range - Closing stock of specific date range;
For example: Total Teritary Sales from 1-Jan-20 to 4-Jan-20 = 5 + 13 - 3 = 15;
- Also Can it be possible to see by date cumulative in a table also like
1-Jan-21 = 0; 2-Jan-21 = 5; 3-Jan-21= 5; 4-Jan-21= 15;
Report Generation Principle:
- By Date or by specific week date range;
- Specific/multiple SKU wise Selection;
- Specific Outlet Wise/ All Outlet
Thank you in advance 🙂
Below is the required tables:
Data Source 1 : Stock Survey Report | ||||
| Date | Outlet Code | Outlet | SKU | Pcs |
| 01-Jan-20 | 10001 | Rahim Store | 200gm | 5 |
| 02-Jan-20 | 10001 | Rahim Store | 200gm | 10 |
| 03-Jan-20 | 10001 | Rahim Store | 200gm | 7 |
| 04-Jan-20 | 10001 | Rahim Store | 200gm | 10 |
| 05-Jan-20 | 10001 | Rahim Store | 200gm | 3 |
| Data Source 2 : Sales Report | ||||
| Date | Outlet Code | Outlet | SKU | Pcs |
| 01-Jan-20 | 10001 | Rahim Store | 200gm | 5 |
| 02-Jan-20 | 10001 | Rahim Store | 200gm | 2 |
| 03-Jan-20 | 10001 | Rahim Store | 200gm | 3 |
| 04-Jan-20 | 10001 | Rahim Store | 200gm | 3 |
| Desire Result : Tertiary Sales - By date | ||||
| Date | Outlet Code | Outlet | SKU | Pcs |
| 01-Jan-20 | 10001 | Rahim Store | 200gm | 0 |
| 02-Jan-20 | 10001 | Rahim Store | 200gm | 5 |
| 03-Jan-20 | 10001 | Rahim Store | 200gm | 0 |
| 04-Jan-20 | 10001 | Rahim Store | 200gm | 10 |
| Result : Tertiary Sales - By Cumulative | ||||
| Date Range | Outlet Code | Outlet | SKU | Pcs |
| 1st Jan to 4th Jan 2020 | 10001 | Rahim Store | 200gm | 15 |
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-_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!
6 Replies
- lbendlinSuper User
Should Closing Stock for a day be the same as opening stock for the same day, or for the next day?
- morabAdvocate I
Closing stock for a day is the opening stock for next day.
- v-kelly-msftCommunity Support
Hi morab ,
First create a calendar dim table;
Then create 2 measures 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]))) var _Salesoftheday=CALCULATE(SUM('Sales Report'[Pcs]),FILTER(ALL('Sales Report'),'Sales Report'[Date]=SELECTEDVALUE('Calendar'[Date]))) var _ClosingStockoftheday=CALCULATE(SUM('Stock Survey Report1'[Pcs]),FILTER(ALL('Stock Survey Report1'),'Stock Survey Report1'[Date]=SELECTEDVALUE('Calendar'[Date])+1)) Return _OpeningStockoftheday+_Salesoftheday-_ClosingStockofthedayTertiary Sales - By Cumulative = SUMX(ALLSELECTED('Calendar'[Date]),'Stock Survey Report1'[By Date Tertirary Sales])And you will see:
For the relalted .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
- Ashish_MathurSuper User
Hi,
In the second table, how did you arrive at 5 pcs as on Jan 2, 2021? It should be -3 i.e. 5+2-10 = -3