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.
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_type | Country | weight | Arith_weight_average_by_fruit_type_and_country |
apples | Spain | 2 | 3 |
apples | Spain | 3 | 3 |
apples | Spain | 4 | 3 |
grapes | Italy | 1 | 1.5 |
grapes | Italy | 2 | 1.5 |
apples | Norway | 3 | 3.5 |
apples | Norway | 4 | 3.5 |
pineapple | Peru | 5 | 5.33 |
pineapple | Peru | 6 | 5.33 |
pineapple | Peru | 5 | 5.33 |
Any hints / Tips apreciated, thanks
Solved! Go to Solution.
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]
)
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!
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
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]
)
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!
@Anonymous , a new column
col = averagex(filter(Table, [Fruit_type] = earlier([Fruit_type] )) , [weight])
@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?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |