Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
Check it out now!Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
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.
@Anonymous
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?
@Anonymous
yes, it should be fine
You could a default SUM aggregation on Number and use "Show as...Percent of grand total".
@Anonymous
@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.
Hi @Anonymous
try a measure
Measure =
DIVIDE(
CALCULATE(SUM(Table[Numbers]), ALLEXCEPT(Table, Table[ID]) ),
CALCULATE(SUM(Table[Numbers]), ALL(Table) )
)