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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Lobo1908
Helper I
Helper I

Limit range of measure to a specific year

Hi, 

 

I'm using the following measure to calculate the annual average for a data set. 

 

Average =
CALCULATE(AVERAGEX(VALUES('Calendar_lookup'[Date].[Year]),[1.2 % of components]), ALLEXCEPT('Calendar_lookup','Calendar_lookup'[Year]))
 

My data covers the whole 2022 year and yet to date 2023. 

Could someone please help me adjust this measure to only catch the avarage for 2022. 

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

Average =

VAR _t1 = YEAR(TODAY())-1

RETURN


CALCULATE(AVERAGEX(VALUES('Calendar_lookup'[Date].[Year]),[1.2 % of components]), ALLEXCEPT('Calendar_lookup','Calendar_lookup'[Year]),'Calendar_lookup'[Year]=_t1)

View solution in original post

6 REPLIES 6
Ahmedx
Super User
Super User

or

or
Average =
VAR _t1 = YEAR(TODAY())-1
RETURN
CALCULATE(AVERAGEX(VALUES('Calendar_lookup'[Date].[Year]),[1.2 % of components]), ALLEXCEPT('Calendar_lookup','Calendar_lookup'[Year]), CALCULATETABLE('Calendar', 'Calendar_lookup'[Year]=_t1))
Ahmedx
Super User
Super User

Average =

VAR _t1 = YEAR(TODAY())-1

RETURN


CALCULATE(AVERAGEX(VALUES('Calendar_lookup'[Date].[Year]),[1.2 % of components]), ALLEXCEPT('Calendar_lookup','Calendar_lookup'[Year]),'Calendar_lookup'[Year]=_t1)

@Ahmedx This one works perfect, thanks very much 

Ahmedx
Super User
Super User

or

Measure =
VAR _t1 = YEAR(TODAY())-1

RETURN
CALCULATE(AVERAGEX(VALUES('Calendar_lookup'[Date].[Year]),[1.2 % of components]), 'Calendar_lookup'[Year]=_t1)

hi @Ahmedx 

 

The problem with your solution is that it eliminates the ALLEXEPT statement, I need to show the average as a straight line on the Line a clustern column chart. Whitout this statment it calculate trhe avarge for every month 

Ahmedx
Super User
Super User


CALCULATE(AVERAGEX(VALUES('Calendar_lookup'[Date].[Year]),[1.2 % of components]), 'Calendar_lookup'[Year]=2022)

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.