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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
mrothschild
Continued Contributor
Continued Contributor

Using average of between slicer to calculate a measure

I have a slicer associated with interest rate integers, i.e., 

4%

5%

6%

7%. . etc.

 

I have a measure that uses the interest rate as a function.  I want my users to be able to insert the range (using a between slicer) and use that as the input into the measure calculation.

 

So if a user enters 5.3% into the bottom and top end of the slicer, I want the measure to return 5.3%.  

 

If a sure enders 4% and 5.5% into the top and bottom end of the slicer, I want the measure to return (4% + 5.5%)/2 = 4.75%

 

I've tried:

 

VAR max_i_rate = MAXX(ALLSELECTED('IRR Sensitivity - Levered'[Interest Rate (rounded)]),'IRR Sensitivity - Levered'[Interest Rate (rounded)])
VAR min_i_rate = MINX(ALLSELECTED('IRR Sensitivity - Levered'[Interest Rate (rounded)]),'IRR Sensitivity - Levered'[Interest Rate (rounded)])
VAR i_rate = (max_i_rate + min_i_rate) / 2
 
RETURN
i_rate
 
but the output is "(Blank)" when entering the same value for the bottom and the top.
 
when I enter 4% and 5.5% the output is 4.5% because, I assume, it's rounding the 5.5% to 5% and then returning (4% + 5.0%)/2
 
What do I need to change about the Measure calculation programming to achieve desired result?
 
Thanks!
4 REPLIES 4
amitchandak
Super User
Super User

@mrothschild , Make sure Levered'[Interest Rate (rounded)] is a decimal number. Also what values you are entering, should be available in the column Levered'[Interest Rate (rounded)]

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak 

 

Is it possible to use a selection that's not available in that column?  

 

For example, if my slicer is set to one decimal place, so the slider moves from 4.0% --> 4.1% --> 4.2% --> 4.3%, etc., but the column data only consists of 4 numbers: 4%, 5%, 6%, 7%, is there a way for me to output (for further calculations) 4.1%, 4.15% [=average of 4.1% and 4.2%], or 4.2%.

 

Or do I need to re-work the underlying data to include all those "empty" rows of data?

@mrothschild , the allselected on the column will force the value from that column only.

 

You can create a series using generateseries having all values

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

 

PBIX Link: https://drive.google.com/open?id=1KXxee9BCMN68eKWgL0PgUEqTlHgklvJm

 

Here's the issue I'm running into trying your suggestion:

 

I have a Matrix that has data populated, which I'd like to constrain with my Slicers (separate from the aforementioned Measure).  When I generate a Parameters table using GENERATESERIES and create a relationship between that table and the underlying Interest Rate column, the Measure works as intended now, but the Matrix no longer works correctly.  

 

For example, here is an abridged screenshot with nothing constrained:

 

No constraints.PNG

 

 

Here is a screenshot with the upper end of Interest Rate column sliced:

 

High constrained.PNG

 

 

In both of the above, the Matrix and the Measure are outputting as I hoped.  The Measure is calculating the average of the range in the Between Slicer, and the Matrix is showing the output values for a 4.0% interest rate.

 

In the following, I've sliced the lower end of the between to 3.9% interest rate.  The 4% interest rate on the Matrix should not be affected by this because it's still within the range of the Slicer.  But all of the data in the Matrix disappear.

 

Low constrained.PNG

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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