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.
Hi,
I need to calculate the ratio of some fields. I have the following data, this is the structure of the data.
ID | Numbers | Date | Hour |
1 | 2 | 05-13-2020 | 10:00 |
1 | 1 | 05-13-2020 | 11:00 |
2 | 3 | 05-13-2020 | 10:00 |
3 | 3 | 05-13-2020 | 10:00 |
3 | 1 | 05-13-2020 | 11:00 |
I need to create a new column or measure, don't know whats better to use, to calculate the ratio.
I need the follow numbers
ID | Ratio |
1 | 30% |
2 | 30% |
3 | 40% |
I can use a measure with SUM('table1'[numbers]) and then use this in a card to show the total numbers. I can also click here in the desktop version to "show percent of grand total" which will give me 100%. When I to this in a table I get the correct numbers as show above.
But I want to show an average of these ratio's and I just can't manage to do this with measure. Because I need the total numbers of a day of all ID together and divide this with the total numbers of the ID itself. In this way you get the ratio of each ID.
I hope someone can help me with this.
You may use the measure below.
Measure =
DIVIDE (
AVERAGEX ( VALUES ( Table1[ID] ), CALCULATE ( SUM ( Table1[Numbers] ) ) ),
CALCULATE ( SUM ( Table1[Numbers] ), ALLSELECTED ( Table1[ID] ) )
)
Thank you both @v-chuncz-msft and @az38 . Both of the solutions works with a measure.
Is this formula also possible to use as an extra column instead of a measure?
You could a default SUM aggregation on Number and use "Show as...Percent of grand total".
@Greg_Deckler Thank you for your reply.
I know I can use a percent of grand total, but I want a measure that's calculation the average of all the ratio's of all ID's. And I can't do that with the "percent of grand total" function. Hope you understand my question, sorry for my garbage English.
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 |
---|---|
113 | |
99 | |
80 | |
70 | |
59 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |