Forum Discussion
Calculating % from a table
I'm new to Power Bi and I'm trying to calculate a % from 2 colums (Made & Missed) in a table but am struggling to figure out how to do it.
I've listed some examples below .
Tackles Made Tackles Missed Tackles Made % (% of total tackles attempted)
10 2 83.3%
12 0 100%
4 1 80%
7 4 63.6%
Any help would be greatly appreciated.
Cheers
J
jamieham , try like
Measure = divide(sum(Table[Tackles Made]),sumx(Table,Table[Tackles Missed]+Table[Tackles Made]))
2 Replies
- TomMartensSuper User
Hey jamieham ,
I created a calculated column (https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-tutorial-create-calculated-columns) using this DAX statement:
Tackles Made % = ROUND( DIVIDE('Table'[Tackles Made] , ('Table'[Tackles Made] + 'Table'[Tackles Missed]) , 0) , 4 ) * 100The table:
But (as always), there is a problem with calculating ratios using calculated columns as the single numbers (each row) be added in the total line, e.g. using a table visual. For this reason, I recommend to create a measure instead:
I use this DAX statement to create a measure (https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-tutorial-create-measures😞
Measure = AVERAGEX( 'Table' , ROUND( DIVIDE('Table'[Tackles Made] , 'Table'[Tackles Made] + 'Table'[Tackles Missed] , 0) , 4) * 100 )Using everything in a table visual makes the difference between calculated columns and measure apparent:
Hopefully, this provides what you are looking for.
Regards,
Tom - amitchandakSuper User
jamieham , try like
Measure = divide(sum(Table[Tackles Made]),sumx(Table,Table[Tackles Missed]+Table[Tackles Made]))