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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculation of averages using data from two different columns as filters.

Afternoon,

I have 3 columns, in first - different products, in second - country of origin, in third - wieght of the product (number).

 

Is it possible to calculate average value of each product for each country separately?

Something like this (in last column is what I want to achieve):

 

Fruit_typeCountryweightArith_weight_average_by_fruit_type_and_country
applesSpain23
applesSpain33
applesSpain43
grapesItaly11.5
grapesItaly21.5
applesNorway33.5
applesNorway43.5
pineapplePeru55.33
pineapplePeru65.33
pineapplePeru55.33

Any hints / Tips apreciated, thanks

1 ACCEPTED SOLUTION
ERD
Super User
Super User

Hi @Anonymous ,

You can use this measure:

 

AvgW =
VAR currentFruit = SELECTEDVALUE ( T[Fruit_type] )
VAR currentCountry = SELECTEDVALUE ( T[Country] )
RETURN
    AVERAGEX (
        FILTER (
            ALL ( T ),
            T[Fruit_type] = currentFruit && T[Country] = currentCountry
        ),
        T[weight]
    )

ERD_0-1632482096192.png

 

 

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

Did the above suggestions help with your requirement? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
ERD
Super User
Super User

Hi @Anonymous ,

You can use this measure:

 

AvgW =
VAR currentFruit = SELECTEDVALUE ( T[Fruit_type] )
VAR currentCountry = SELECTEDVALUE ( T[Country] )
RETURN
    AVERAGEX (
        FILTER (
            ALL ( T ),
            T[Fruit_type] = currentFruit && T[Country] = currentCountry
        ),
        T[weight]
    )

ERD_0-1632482096192.png

 

 

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

amitchandak
Super User
Super User

@Anonymous , a new column

 

col = averagex(filter(Table, [Fruit_type] = earlier([Fruit_type] )) , [weight])

Anonymous
Not applicable

@amitchandak  many thanks for helping me out. It solves half of my issue. 

By using the expression that you have provided i got average weight by fruit_type. But it has averaged the fruits from different country. 
Making it short - i need to apply 2 filters: by fruit type and by country.

Any clues how it can be done?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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