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
mbmcdonald2
Helper II
Helper II

Trouble Calculating a Dynamic Average

Hi All,

 

I am trying to add a new measure that dynamically calculates the average of all the values based on the parameter selection and I am getting an error saying "parameter is not the correct type". I would like this new column to spit out the 17 that is highlighted in the screenshot below. 

 

Any help is greatly appreciated.

 

thank you!

 

mbmcdonald2_0-1733252857922.png

mbmcdonald2_1-1733252887442.png

 

 

1 ACCEPTED SOLUTION

Hi @mbmcdonald2 ,

 

Create this measure.

 

Average Score = 
CALCULATE ([Score], ALLSELECTED('OST'))

 

vtangjiemsft_0-1733884161108.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

15 REPLIES 15
v-tangjie-msft
Community Support
Community Support

Hi @mbmcdonald2 ,

 

It works fine through my tests. Can you provide sample pbix files (taking care to protect private data) for us to test?

vtangjiemsft_1-1733815402305.png

 

vtangjiemsft_0-1733815196102.png

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi Neeko,

 

Please find a sample file here

 

Please let me know if you have any troubles with access.

 

Thanks!

Maggie

Hi @mbmcdonald2 ,

 

Create this measure.

 

Average Score = 
CALCULATE ([Score], ALLSELECTED('OST'))

 

vtangjiemsft_0-1733884161108.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi there,

 

Thank you so much for the help on this. It appears that while that solution worked for that particular instance, I am having trouble applying correctly to another instance. As you see in the screenshot, the "total" is showing as 19, however, that is incorrect as the average should be closer to 9. Do you have any idea why this might be?

 

Appreciate any assistance here in advance. Thank you so much!

 

mbmcdonald2_0-1733943655353.png

 

Hi @v-tangjie-msft - just following up on the above. If you have any insight into this it would be greatly appreciated. Thank you!

This worked! Thank you so much everyone for all of the assistance!

v-tangjie-msft
Community Support
Community Support

Hi @mbmcdonald2 ,

 

Thanks to Dangar332  and FreemanZ  for their quick replies. I have some other thoughts to add:

Based on your description, the Score you are displaying on the visual object is the measure, correct? If I have misunderstood you please clarify in a follow up reply.
Then we can create a new measure.

Avg = CALCULATE([Score],ALLSELECTED('Table'))

Then the result is as follows.

vtangjiemsft_0-1733455782195.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi All,

 

Thanks so much for your continuous help here. 

 

The one challenge here is that the "sub-category" field comes from a parameter, which I believe may require some differences in the formula. 

 

You'll see when I create the formula per your suggestion: 

Average Score =
CALCULATE ([Score], ALLSELECTED('Field Select Parameter'))
I get the same figures as my existing column.
mbmcdonald2_0-1733496797886.png

 

 

hi @mbmcdonald2 ,

 

could you depict your expected result with a table?

Hi there! Can you please clarify what you mean?

FreemanZ
Super User
Super User

hi @mbmcdonald2 ,

 

try like:

average =

AVERAGEX(

    VALUES(data[sub category]),

    [KO Profitability Score]

)

Hi there,

 

Thanks so much for getting back to me. So when I update per your suggestion above I just get the same values, not the '17' value I was expecting. The first column is based on a parameter and changes between category and sub-category. 

 

Average KO Profitability Score = averagex (VALUES('Field Select Parameter'[Selection Parameter Fields]),
[KO Profitability Score])
 
mbmcdonald2_0-1733330152801.png

 

 

Hi, @mbmcdonald2 

Try below amended measure 

Average KO Profitability Score = 
averagex (
 allselected(
      'Field Select Parameter'[Selection Parameter Fields]),
       [KO Profitability Score]
)

 

Best Regards,
Dangar

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi there,

 

Thanks so much for your help. The solution is now showing up like this (it should show up as all 17s) using the above formula.

 

mbmcdonald2_0-1733343548530.png

 

Dangar332
Super User
Super User

Hi, @mbmcdonald2 

You had used a measure as Average argument where it's only accept Column refrence not Measure, try to put score column that shown in screenshot .



 

 

Best Regards,
Dangar

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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!

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.