Forum Discussion

morab's avatar
morab
Icon for Advocate I rankAdvocate I
5 years ago
Solved

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 - ...
  • v-kelly-msft's avatar
    v-kelly-msft
    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-_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!