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.
Dear community!
I want to calculate the median age of all cars in this this dataset but I can't get a grip of how to do it in DAX. It's like calculating the median of a distribution function. For example: The answer here for Mazda is three months. (total number of Mazda+ 1)/2 = 262 which corresponds to three months (larger than 232 but less than 367). But I also need to do the calculation for all brands.
I would guess the answer involves MedianX and Summarize but hopefully someone now how to put them togheter as well 🙂
BR Thomas
Brand | Age of car in months | Number of cars | Cumulative number of Cars |
Mazda | 0 | 100 | 100 |
Mazda | 1 | 50 | 150 |
Mazda | 2 | 82 | 232 |
Mazda | 3 | 135 | 367 |
Mazda | 4 | 20 | 387 |
Mazda | 5 | 61 | 448 |
Mazda | 6 | 75 | 523 |
Kia | 0 | 32 | |
Kia | 1 | 41 | |
Kia | 2 | 80 | |
Kia | 3 | 120 | |
Kia | 4 | 130 | |
Kia | 5 | 50 |
Solved! Go to Solution.
Hi,
Please check the below measures and the attached pbis file.
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi,
Please check the below measures and the attached pbis file.
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Many thanks Jihwan_Kim, kudos!
I have tried it out and it works perfectly fine 👍
Just one adjustment, if you are to use it witout the column "brand" (i.e Median of all cars) you have to change:
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 |
---|---|
45 | |
25 | |
19 | |
16 | |
8 |
User | Count |
---|---|
71 | |
49 | |
45 | |
20 | |
17 |