Forum Discussion

mrhish's avatar
mrhish
Frequent Visitor
2 years ago
Solved

Adding output previous week with a fixed "step" output

Hi!

I am working on a forecast model where we need to predict future output based on history.

 

What I have is a fixed "Step" output (which I calculated based on historical data). Lets say this step equals 150. What I want to create is a measure which calculates forecast output each week by 150 + the previous week forecast output. The tricky thing is that the first week (min week) should be the minimum of the actual output for the given period. I have a calendar connected to the output fact table. 

 

Anyone have any idea how I can get the Forecast output? 


Actual output

YearWeekOutput
20235015
20235150
20235240
202414
2024270
20243150
20244200
20245300

 

Forecast output (what I want to achieve)

YearWeekForecast Output
20235015
202351165 (150+15)
202352315 (150+165)
20241465 (150+315)
20242615 (150+465)
20243765 (150+615)
20244915 (150+765)
202451065 (150+915)

12 Replies

  • mrhish 

    do you have the date table in your model? i think the actual output is a table visual. could you pls provide some sample data?

  • mrhish's avatar
    mrhish
    Frequent Visitor

    ryan_mayu I do have a date table connected to the fact table where the actual ouput is. So its a simple model with a date table connected to the fact table. 

      • mrhish's avatar
        mrhish
        Frequent Visitor

        Thanks for your suggested solution, its definetly close. Problem is that I have ouput from from two years in my model (from mid 2023 until today). So the "week2" column gives incorrect week numbers with your calculation. Is there any way we can write a calculated week2 column which takes this into consideration? 

  • do you want to show this to using measure or  genarating table ? 

    if using measure
    create measuer ,

    forcast_output = 
    var output = [output]
    var y  = selectedvalue([year])
    var w = selectedvalue([week])-1
    var a = calculatetable(min([output]),filter('Actual output',[year]=a && [week]=w))
    var b = a+150
    return b

    then create visual table with column, year, week, and our new measure(forecast_output)