Forum Discussion

vipett's avatar
vipett
Icon for Helper III rankHelper III
4 years ago
Solved

Calculate sum on a given date

I have a crossjoined table with all dates and all my articles and then I have one column where I store all my transactions, plus and minus (which do not occur every day).

 

Through this measure: 

SOH2 = CALCULATE(
     SUM(JB[ConsumptionTTL]),
     FILTER(
     ALL(JB[CalenderDate]),
        (JB[CalenderDate])<=MAX(JB[CalenderDate])
)
 
I can calculate what the stock was on any given day and aswell as forecasted stock in the future.
However, no I would like to have a measure that shows me the projected stock on 2022-12-31 and compare this to today's stock level, so I can identify what items are increasing / decreasing.
I can put the measure in a table and set the date to 2022-12-31 to see what stock value I will have, but I want to be able to use it in calculations as well.
  • Okey, so I found an really ugly way of solving it, but at least it works..

    I added a table and just entered 2022-12-31 in one cell, then created a new measure where I calculated the previous measure and put that the date should be equal to the sum in that new table.. 

    Don't really understand why I couldn't say that date = 2022-12-31 but yeah.. it works now at least. But there might be a nicer solution..

     

    End of Year = CALCULATE([SOH]2, JB[CalenderDate]=SUM('EndOfYear'[Column1]))

9 Replies

  • Do you want to use the built in forecasting functions or do you want to create your own?  Which algorithm are you planning to use?  Where should it start?  Do you want it to be adaptive to the seasonal changes?

    • vipett's avatar
      vipett
      Icon for Helper III rankHelper III

      Hi,

       

      The forecast is calculated elsewhere.

      In this report I only have all historical transactions and future forecasted transactions per day. The measure I have today accumulates these numbers to show what stock levels I had a specific day and what stock levels I will have on a specific day in the future. 

      But yeah, the future demand is pre-calculated elsewhere and I am only seeking the accumulated number here.

  • Hi,

    There should be a Calendar Table with a relationship (Many to One and Single) from the CalendarDate column of the JB table to the Date column of the Calendar Table.  Write this measure

    Measure = calculate(SUM(JB[ConsumptionTTL]),datesbetween(Calendar[Date],date(2022,12,31),date(2022,12,31)))

    Hope this helps.

    • vipett's avatar
      vipett
      Icon for Helper III rankHelper III

      Hi,

       

      This only genereates an empty table 😞 (did however write the date as 2022-12-31)

      My source table "ConsumptionTTL" only contains actual numbers and since this is in the future, the measure I use today calculates an accumulated value based on the previous transactions.

    • vipett's avatar
      vipett
      Icon for Helper III rankHelper III

      It can't see that it provides a solution for my exact question, I see how ever that I could potentially get some help and clean up the graph, currently it looks like this, where the black line is actual and it continues straight after today's date. The blue line is the forecast. Ideally I want the black line to stop on today's date.

  • Okey, so I found an really ugly way of solving it, but at least it works..

    I added a table and just entered 2022-12-31 in one cell, then created a new measure where I calculated the previous measure and put that the date should be equal to the sum in that new table.. 

    Don't really understand why I couldn't say that date = 2022-12-31 but yeah.. it works now at least. But there might be a nicer solution..

     

    End of Year = CALCULATE([SOH]2, JB[CalenderDate]=SUM('EndOfYear'[Column1]))