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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Calculate Monthly Average and sum multiple months average

Hi Team, I have a requirement to average the monthly sales and sum the monthly averages when we select multiple months.

 

I have a Salestable as below. If I filter for Product = "Watch" and YearMonth = "Jan-2022" then I want to see the total average of Watch for the month of Jan 2022 (i.e., 999). - Which is working fine. But

If I filter for Product = "Watch" and selected multiple months or multiple years like YearMonth = "Jan-2022" and "Feb-2022" then I want to see the total sum of both months average (i.e., Jan-2022 = 999 and Feb-2022 = 894 so my result should be 999+894 =1893).

 

SalesTable:

ProductSaleDateYearmonthPrice
Watch1-Jan-22Jan-2022999
Watch10-Jan-22Jan-2022999
Watch1-Feb-22Feb-2022894
Watch15-Feb-22'Feb-2022894
Watch1-Apr-22Apr-2022434
Pen1-Mar-22Mar-202232
Pen14-Mar-22Mar-202235
Pen9-Apr-22Apr-202222
Table1-Jan-22Jan-2022999
Table10-Jan-22Jan-2022999

I need this to be implemented in a measure. Can someone please help me with the same?

 

Thanks!!

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous;

You could create a measure.

Measure = SUMX(SUMMARIZE('Table',[Product],[Yearmonth],[Price]),[Price])

 The final output is shown below:

vyalanwumsft_0-1655176171156.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous;

You could create a measure.

Measure = SUMX(SUMMARIZE('Table',[Product],[Yearmonth],[Price]),[Price])

 The final output is shown below:

vyalanwumsft_0-1655176171156.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

johnt75
Super User
Super User

Sum Average = 
var summaryTable = ADDCOLUMNS( SUMMARIZE('Table', 'Table'[Product], 'Table'[Yearmonth] ),
    "@avg", CALCULATE( AVERAGE('Table'[Price]))
)
return SUMX( summaryTable, [@avg] )
Anonymous
Not applicable

@johnt75 - Thanks for your swift response! I had applied your logic, but I'm getting a big number when I filter for multiple months

 

Anonymous
Not applicable

CALCULATE (
    SUMX (
        SUMMARIZE (
            TABLE,
            TABLE[PRODUCT],
            TABLE[YearMonth],
            "@AVG", FIRSTNONBLANK( TABLE[PRICE],0 )
        ),
        [@AVG]
    )
)

 

I wrote this logic and it is working as expected. however the totals are showing 0. Can you please help me here @johnt75 ?

 

Not sure what you're trying to get with FIRSTNONBLANK. The measure I posted did work with multiple months selected

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.

Top Solution Authors
Top Kudoed Authors