Forum Discussion

bcap01's avatar
bcap01
Helper II
3 years ago

DAX Calculation Not Working

I would like to combine the value of (2) fields to determine percetage of Billable hours.

 

For example, what I would like to do is this:  ChargeableHours/(ChargeableHours+NonChargableHours) or 158/(158+322) = 32.91%.

 

Here is my DAX:

P% = (table[ChargeHours])/(table[TotalHours])
 
For some reason I am getting a different percentage than expected.  What adjustment do I need to make this work?

 

 

5 Replies

  • hi bcap01 

     

    is P% a calculated column or measure? please consider provide some sample data to well reflect your case. 

  • FreemanZ 

     

    Many thanks for your reply!  Below is what my data looks like.  What seems to be happening is the UTil% column is accuminating/adding instead of doing the desired calculation of ChargeHours/TotalHours.

     

    TotalHours is a column I made which is:  ChargeHours + NonCHargeHours. 

    ChargeHours and NonChargeHours are fields from the database table I am importing.

     

    Many help is greatly appreciated!

    • FreemanZ's avatar
      FreemanZ
      Super User

      hi bcap01 

      try like:

      Util% =
      DIVIDE(
          SUM(TableName[ChargeHours]),
          SUM(TableName[TotalHours])
      )

       

  • Thanks again FreemanZ ,

     

    For some reason the Matrix is still accuminating instead of doing the calculation.  Perhaps do I need to do CALCULATE somewhere?