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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Measure not working, when calculated column worked. Using Average.

I have a table with the columns "Value", "Analyte", "Color", "AnalyteType" and "DateEnter". I created a calculated column that averages by all those groups and takes only the last 12 months of data. I would like to move this to a measure though, so I can change which data is used on the fly.

 

ValueAnalyteColorAnalyteTypeDateEnter
5.44BalloonBlueLab2022/05/04
62.5CarRedLab2022/03/11
11.5CarPurpleOutside2022/02/08
78.1ChairBlueIndoor2022/04/22

 

Here is the calculated column that works:

 

Column1 = calculate(average(Main[Value]),filter(Main,Main[Analyte]=EARLIER(Main[Analyte])),filter(Main,Main[Color]=EARLIER(Main[Color])),filter(Main,Main[AnalyteType]="Lab"),filter(Main,Main[DateEnter]>today()-365))

 

Here is the measure I tried:

 

MeasureDiffs =
average(calculate(average(Main[Final]),filter(Main,Main[Analyte]=EARLIER(Main[Analyte])),filter(Main,Main[Color]=EARLIER(Main[Color])),filter(Main,Main[AnalyteType]="Lab")))
 
I get the error "The AVERAGE function only accepts a column reference as an argument". I don't understand because it did work as a column in the data table. Any ideas?
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try like

 

calculate(average(Main[Final]),filter(allselected(Main),Main[Analyte]=Max(Main[Analyte]) &&  Main[Color]=Max (Main[Color]) && Main[AnalyteType]="Lab"))

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Try like

 

calculate(average(Main[Final]),filter(allselected(Main),Main[Analyte]=Max(Main[Analyte]) &&  Main[Color]=Max (Main[Color]) && Main[AnalyteType]="Lab"))

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
Anonymous
Not applicable

That worked great. Why use the "Max" instead of "Earlier"?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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