Use a function in a custom field in pivot table

Copper Contributor

I'm trying to add a custom field to a pivot table using sumif function.

My data has records for both hours and OT.  I would like a pivot table to show the total hours for all types i.e. (Reg, OT, Sick time, etc) .  The custom field I need to add would sum all OT hours and divide by the total hours. I'm looking for the best way to do this

1 Reply

Hi Jack,

 

If your table is added to data model you may right click on table name like here

image.png

and add measure

=CALCULATE(SUM(Table1[Hours]),Table1[Type]="OT")/CALCULATE(SUM(Table1[Hours]),ALL(Table1[Type]))

or divide on SUM to show % of OT to all other types.

Please see attached.