Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Calculate rolling average for future 7 days

Hi . I want to generate forecast which is 7 days rolling average of past days. This forecast should be generated for next 7 days based on latest date in [MV_START_DT_NEW] column . The average should be generated by grouping cluster , plant and product description. Below is the data sample and expected output columns highlighted in yellow

 

 

Cluster_newGSAP_PLANT_MAPPEDProduct DescriptionMV_START_DT_NEWSum_Inv (BBL)Forecasted valueFuture forecast dates
NYHNEY826ETHANOL5/17/2024-119.380952410.337210885/24/2024
NYHNEY826ETHANOL5/18/2024-133.571428610.337210885/25/2024
NYHNEY826ETHANOL5/19/2024-134.833333310.337210885/26/2024
NYHNEY826ETHANOL5/20/2024-137.738095210.337210885/27/2024
NYHNEY826ETHANOL5/21/2024-195.476190510.337210885/28/2024
NYHNEY826ETHANOL5/22/2024920.690476210.337210885/29/2024
NYHNEY826ETHANOL5/23/2024-127.3310.337210885/30/2024
RG3SWY001PUL5/17/2024108.59523815.645/24/2024
RG3SWY001PUL5/18/2024-39.047619055.645/25/2024
RG3SWY001PUL5/19/2024-30.880952385.645/26/2024
RG3SWY001PUL5/20/202426.40476195.645/27/2024
RG3SWY001PUL5/21/2024-173.0476195.645/28/2024
RG3SWY001PUL5/22/2024193.02380955.645/29/2024
RG3SWY001PUL5/23/2024-124.5476195.645/30/2024
COLOY01QDIESEL5/17/2024-401.78571431495/24/2024
COLOY01QDIESEL5/18/2024-70.880952381495/25/2024
COLOY01QDIESEL5/19/2024-122.19047621495/26/2024
COLOY01QDIESEL5/20/2024-129.64285711495/27/2024
COLOY01QDIESEL5/21/2024-193.26190481495/28/2024
COLOY01QDIESEL5/22/2024-44.619047621495/29/2024
COLOY01QDIESEL5/23/2024-83.709523811495/30/2024
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous,

    You can try to use the following measure formulas if it sutiabel for your requirement:

    Rolling AVG =
    VAR currDate =
        MAX ( Table1[MV_START_DT_NEW] )
    RETURN
        AVERAGEX (
            SUMMARIZE (
                FILTER ( ALLSELECTED ( Table1 ), [MV_START_DT_NEW] <= currDate - 7 ),
                [Cluster_new],
                [GSAP_PLANT_MAPPED],
                [Product Description],
                "Total", SUM ( Table[Sum_Inv (BBL)] )
            ),
            [Total]
        )
    

    Regards,

    Xiaoxin Sheng

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous,

    You can try to use the following measure formulas if it sutiabel for your requirement:

    Rolling AVG =
    VAR currDate =
        MAX ( Table1[MV_START_DT_NEW] )
    RETURN
        AVERAGEX (
            SUMMARIZE (
                FILTER ( ALLSELECTED ( Table1 ), [MV_START_DT_NEW] <= currDate - 7 ),
                [Cluster_new],
                [GSAP_PLANT_MAPPED],
                [Product Description],
                "Total", SUM ( Table[Sum_Inv (BBL)] )
            ),
            [Total]
        )
    

    Regards,

    Xiaoxin Sheng

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for responding Anonymous . However I am not able to plot this measure and getting below error