Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

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!

 

 

 

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Anonymous ,

     

    Create this measure.

     

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

     

    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. 

15 Replies

  • Dangar332's avatar
    Dangar332
    Resident Rockstar

    Hi, Anonymous 

    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.

  • hi Anonymous ,

     

    try like:

    average =

    AVERAGEX(

        VALUES(data[sub category]),

        [KO Profitability Score]

    )

    • Anonymous's avatar
      Anonymous
      Not applicable

      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])
       

       

       

      • Dangar332's avatar
        Dangar332
        Resident Rockstar

        Hi, Anonymous 

        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.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    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.

    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. 

    • Anonymous's avatar
      Anonymous
      Not applicable

      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.

       

       
      • FreemanZ's avatar
        FreemanZ
        Super User

        hi Anonymous ,

         

        could you depict your expected result with a table?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Neeko,

       

      Please find a sample file here

       

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

       

      Thanks!

      Maggie

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        Create this measure.

         

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

         

        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.