Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
vipett
Helper III
Helper III

Weekly average based on previous six months data

I have a table that basically looks liks this:

 

DateArticleConsumption
2022-06-01A5
2022-05-03A4
2022-06-03B2
2022-06-01B4
2022-05-15B5
2022-06-04A3

 

I would like to have a calculated column where I get the average consumption by week and only based on the previous six months data. It should be separated by article and article

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @vipett,

Did you mean to get the weekly total and average of rolling six months? If that is the case, you can try to use the following formula:

Formula =
AVERAGEX (
    SUMMARIZE (
        ADDCOLUMNS (
            FILTER (
                Table,
                [Date]
                    >= DATE ( YEAR ( EARLIER ( Table[Date] ) ), MONTH ( EARLIER ( Table[Date] ) ) - 6, DAY ( EARLIER ( Table[Date] ) ) )
                    && [Date] <= EARLIER ( Table[Date] )
                    && [Article] = EARLIER ( Table[Article] )
            ),
            "WeekNumber", WEEKNUM ( [Date], 2 ),
            "Year", YEAR ( [Date] )
        ),
        [Year],
        [WeekNumber],
        "Total", SUM ( Table[Consumption] )
    ),
    [Total]
)

Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

HI @vipett,

Did you mean to get the weekly total and average of rolling six months? If that is the case, you can try to use the following formula:

Formula =
AVERAGEX (
    SUMMARIZE (
        ADDCOLUMNS (
            FILTER (
                Table,
                [Date]
                    >= DATE ( YEAR ( EARLIER ( Table[Date] ) ), MONTH ( EARLIER ( Table[Date] ) ) - 6, DAY ( EARLIER ( Table[Date] ) ) )
                    && [Date] <= EARLIER ( Table[Date] )
                    && [Article] = EARLIER ( Table[Article] )
            ),
            "WeekNumber", WEEKNUM ( [Date], 2 ),
            "Year", YEAR ( [Date] )
        ),
        [Year],
        [WeekNumber],
        "Total", SUM ( Table[Consumption] )
    ),
    [Total]
)

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.