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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
skfinegan
Regular Visitor

Multiple IF conditions with averageX

I currently have the following IF statement to calculate the avg of the previous day's data if greater than 0.4. However, now I need to add a high limit of 2. So really I want it to take the avg of all values between 0.4 and 2. However, I am getting an error messge that "Too many arguments were passed to the AVERAGEX function. The maximum argument count for the function is 2."

 

Here is my formula with just the lower limit. 

AVG CH7 = AVERAGEX(FILTER('Kw/ton','Kw/ton'[Date]=EARLIER('Kw/ton'[Date])),if('Kw/ton'[Chiller7_KW_Ton_value (kW)]<0.4,BLANK(),'Kw/ton'[Chiller7_KW_Ton_value (kW)]))
 
Here is it with trying to implement the high limit. 
AVG CH6 = AVERAGEX(FILTER('Kw/ton','Kw/ton'[Date]=EARLIER('Kw/ton'[Date])),if('Kw/ton'[Chiller6_KW_Ton_value (kW)]<0.4,BLANK(),'Kw/ton'[Chiller6_KW_Ton_value (kW)]),if('Kw/ton'[Chiller6_KW_Ton_value (kW)]>2,BLANK(),'Kw/ton'[Chiller6_KW_Ton_value (kW)]))
 
Any help would be greatly appreciated!
1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@skfinegan 

You cannot use if statement as the expression. To get the average between of all values between 0.4 and 2, try add the conditions in the filters: 

 

CALCULATE(AVERAGE('Kw/ton'[Chiller7_KW_Ton_value (kW)]),FILTER('Kw/ton','Kw/ton'[Chiller7_KW_Ton_value (kW)]>0.4 && 'Kw/ton'[Chiller7_KW_Ton_value (kW)]< 2),FILTER('Kw/ton','Kw/ton'[Date]= EARLIER('Kw/ton'[Date])))

 

 

 

 

Paul Zheng

View solution in original post

1 REPLY 1
V-pazhen-msft
Community Support
Community Support

@skfinegan 

You cannot use if statement as the expression. To get the average between of all values between 0.4 and 2, try add the conditions in the filters: 

 

CALCULATE(AVERAGE('Kw/ton'[Chiller7_KW_Ton_value (kW)]),FILTER('Kw/ton','Kw/ton'[Chiller7_KW_Ton_value (kW)]>0.4 && 'Kw/ton'[Chiller7_KW_Ton_value (kW)]< 2),FILTER('Kw/ton','Kw/ton'[Date]= EARLIER('Kw/ton'[Date])))

 

 

 

 

Paul Zheng

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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