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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
vipett
Helper II
Helper II

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
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors