Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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:
User | Count |
---|---|
50 | |
23 | |
18 | |
18 | |
14 |
User | Count |
---|---|
91 | |
85 | |
46 | |
28 | |
21 |