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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
fjordy
New Member

Problem with AVERAGEIFs

Hello everyone,

I have a problem that took me a few hours to solve and I couldn't 😞
I have the following data structure:

CountryYearMonthProductReceiverVolumeRazão
USA20141SojaChina5354185Real
USA20151SojaChina5260912Real
USA20161SojaChina3261607Real
USA20171SojaChina3483983Real
USA20181SojaChina2690972Real
USA20191SojaChina132999Real
USA20201SojaChina2323474Real
USA20211SojaChina5122018Real
USA20221SojaChina3308130Real
USA20231SojaChina6224062Real

 

notice that there are several years and also several months (in this example I put only month 1), in powerbi I already used the conditions "AVERAGEIFS", AVERAGEX with GROUPBY and CALCULATE with FILTER to make the correct average for each month grouping the last five years - for example the average of month 1 of the years 2018 to 2022, but nothing works, it makes an average that definitely the values are incorrect.

Can someone help me please? :'(

1 ACCEPTED SOLUTION

Thank you very much, as it was not a date format I had to use another formula, I managed it as follows:

Average 5 years =
VAR CurrentYear = MAX('Amzr Evolution UF'[Year])-1
VAR LastYear = CurrentYear - 4
VAR TotalVolume = SUMX(
FILTER(
CALCULATETABLE(
'Exp Consolidated',
'Consolidated Exp'[Year] >= LastYear && 'Consolidated Exp'[Year] <= CurrentYear && 'Consolidated Exp'[Volume] <> 0
),
'Consolidated Exp'[Month] = MAX('Consolidated Exp'[Month])
),
'Consolidated Exp' [Volume]
)
VAR QtyYears = 5
RETURN DIVIDE(TotalVolume,QtyYears)

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@fjordy ,

You can try measure like

 

AVERAGEX(Values(Date[Month Year]) , calculate(Sum(Table[Volume])))

 

I assumes you are using date table with month year

 

or

 

AVERAGEX(Summarize(Table,Table[Year], Table[Month], "_1" , calculate(Sum(Table[Volume]))), [_1])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you very much, as it was not a date format I had to use another formula, I managed it as follows:

Average 5 years =
VAR CurrentYear = MAX('Amzr Evolution UF'[Year])-1
VAR LastYear = CurrentYear - 4
VAR TotalVolume = SUMX(
FILTER(
CALCULATETABLE(
'Exp Consolidated',
'Consolidated Exp'[Year] >= LastYear && 'Consolidated Exp'[Year] <= CurrentYear && 'Consolidated Exp'[Volume] <> 0
),
'Consolidated Exp'[Month] = MAX('Consolidated Exp'[Month])
),
'Consolidated Exp' [Volume]
)
VAR QtyYears = 5
RETURN DIVIDE(TotalVolume,QtyYears)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.