Forum Discussion

DoeJohn's avatar
DoeJohn
Frequent Visitor
3 years ago

Carried Over Beginning Balance from Previous Period Ending Balance

Hi All!

I have a confusion finding the right way to get carried over beginning cost value from previous period ending cost. I have read about recursion in power BI and I try to avoid it. Please suggest the most efficient way to solve this in power BI!!
I provide the sample data here as well. Please do ask if there's any question! Thanks ðŸ˜€

Formula:
1. Ending Cost = ((Beginning Cost * Beginning Volume) + (Production Cost * Production Volume)) / (Beginning Volume + Production Volume)
2. Beginning Volume = Prev. month Beginning Volume + Prev. month Production Volume - Prev. month Sales Volume

 

Logic      
MonthBeginning CostBeginning VolumeProduction CostProduction VolumeSales VolumeEnding Cost (Average Cost)
Jan-231003797202398,95
Feb-2398,9534101305099,91
Mar-2399,911493343795,02

 

Input      
MonthBeginning CostBeginning VolumeProduction CostProduction VolumeSales VolumeEnding Cost (Average Cost)
Jan-2310037972023 
Feb-23  1013050 
Mar-23  933437 

 

Expected Output  
MonthBeginning CostEnding Cost (Average Cost)
Jan-23100,00                                       98,95
Feb-2398,95                                       99,91
Mar-2399,91                                       95,02

3 Replies

  • DoeJohn , for the previous month you can use Time Intelligence

     

    example

     

    MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
    last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
    last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
    MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
    last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
    last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))

     

    Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
    Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
    Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

     

     

    Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
    https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5bd4
    To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

  • DoeJohn's avatar
    DoeJohn
    Frequent Visitor

    Hi Amitchandak,

    Thanks for the reply!

    However, while current month beginning cost is prev month ending cost, current month ending cost is dependent on current month beginning cost. Thus, when writing the formula I got circular dependency error since they are dependent on each other...

    Thanks,
    John