The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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.
Hi,
Please check the below measures and the attached pbis file.
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 |
---|---|
15 | |
8 | |
6 | |
6 | |
5 |
User | Count |
---|---|
25 | |
13 | |
13 | |
8 | |
8 |