Forum Discussion

bryanrendra's avatar
bryanrendra
Icon for Helper II rankHelper II
6 years ago
Solved

Forecasting 2 years ahead for Multiple items

I have a table with multiple items. each items has different prices every year. I just want to make a prediction or forecasting for the next 2 years based on the 2020 price and ignore the item that d...
  • amitchandak's avatar
    6 years ago

    bryanrendra , Try like

    meausre =
    var _max = year(today)
    return
    calculate(if(max(Year[Year]) >=_max, Average(Table[Price]) ,Averagex(filter(all(Year),Year[Year]=_max),Table[Price])*power(1.1,Max(Year[Year])-max)))
  • Icey's avatar
    6 years ago

    Hi bryanrendra ,

     

    Please check:

     

    1. Enter data to create a Year table. 

     

    2. Create a measure like so:

    Meausre 2 = 
    VAR t1 =
        ADDCOLUMNS (
            'Table',
            "MaxYear", CALCULATE (
                MAX ( 'Table'[Year] ),
                FILTER (
                    'Table',
                    'Table'[Book] = EARLIER ( 'Table'[Book] )
                        && 'Table'[Genre] = EARLIER ( 'Table'[Genre] )
                )
            )
        )
    VAR t2 =
        FILTER ( t1, [MaxYear] = 2020 && [Year] = 2020 )
    VAR t3 =
        CROSSJOIN ( SUMMARIZE ( t2, [Book], [Genre], [Price] ), { 2021, 2022 } )
    VAR t4 =
        ADDCOLUMNS ( t3, "price_", [Price] * POWER ( 1.1, [Value] - 2020 ) )
    VAR t5 =
        UNION ( 'Table', SUMMARIZE ( t4, [Book], [Genre], [Value], [price_] ) )
    RETURN
        IF (
            HASONEVALUE ( 'Year'[Year_] ),
            SUMX ( FILTER ( t5, [Year] = MAX ( 'Year'[Year_] ) ), [Price] ),
            SUMX ( t5, [Price] )
        )
    

     

    3. Then you will get this:

    BTW, .pbix file attached.

     

     

    Best Regards,

    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.