Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Average in Power Bi

Hi,

Please could you kindly assist with the below.

I would like to calculate the Average value of a country Spain and Portugal. (This product is in multiple rows within my workbook). When i calculate the average it gives me the total average of all the rows combined and not the single average Value. Please see below my formula, what can i do to tweek it so it provides a single units average.

Average = CALCULATE(AVERAGE(Sheet1[Percentage]),FILTER(Sheet1,Sheet1[Country] = "Spain" && Sheet1[Country] = "Portugal"))

 

Thanking you in advance for you help.

Regards,
Ridwan

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    The reason is here:

    FILTER(Sheet1,Sheet1[Country] = "Spain" && Sheet1[Country] = "Portugal")

    When we filter the table, we can't find rows that are both "Spain" and "Portugal", so this always returns blank.

     

     Did some editing, replace && (AND) with || (OR).

    Average =
    CALCULATE (
        AVERAGE ( Sheet1[Percentage] ),
        FILTER ( Sheet1, Sheet1[Country] = "Spain" || Sheet1[Country] = "Portugal" )
    )

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data

2 Replies

  • Anonymous , Try like

     

    Average = CALCULATE(AVERAGE(Sheet1[Percentage]),FILTER(Sheet1,Sheet1[Country] in { "Spain" ,"Portugal" } ))

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    The reason is here:

    FILTER(Sheet1,Sheet1[Country] = "Spain" && Sheet1[Country] = "Portugal")

    When we filter the table, we can't find rows that are both "Spain" and "Portugal", so this always returns blank.

     

     Did some editing, replace && (AND) with || (OR).

    Average =
    CALCULATE (
        AVERAGE ( Sheet1[Percentage] ),
        FILTER ( Sheet1, Sheet1[Country] = "Spain" || Sheet1[Country] = "Portugal" )
    )

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data