Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
JeroenR
Helper V
Helper V

Calculate ratio

Hi,

 

I need to calculate the ratio of some fields. I have the following data, this is the structure of the data. 

IDNumbersDateHour
1205-13-202010:00
1105-13-202011:00
2305-13-202010:00
3305-13-202010:00
3105-13-202011: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

IDRatio
130%
230%
340%

 

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. 

6 REPLIES 6
v-chuncz-msft
Community Support
Community Support

@JeroenR 

 

You may use the measure below.

Measure =
DIVIDE (
    AVERAGEX ( VALUES ( Table1[ID] ), CALCULATE ( SUM ( Table1[Numbers] ) ) ),
    CALCULATE ( SUM ( Table1[Numbers] ), ALLSELECTED ( Table1[ID] ) )
)

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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? 

az38
Community Champion
Community Champion

@JeroenR 

yes, it should be fine


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Greg_Deckler
Super User
Super User

You could a default SUM aggregation on Number and use "Show as...Percent of grand total".

 

@JeroenR 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@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.

az38
Community Champion
Community Champion

Hi @JeroenR 

try a measure

Measure = 
DIVIDE(
CALCULATE(SUM(Table[Numbers]), ALLEXCEPT(Table, Table[ID]) ),
CALCULATE(SUM(Table[Numbers]), ALL(Table) )
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.