Forum Discussion

Dougers1's avatar
Dougers1
Frequent Visitor
2 years ago
Solved

help with formula to calculate time

Hi

 

i am having issues with trying to get hours counted, i want it to return Substantive Filled total hours

Month StatusHours
OctSubstantive Filled01:00:00
OctFilled01:00:00
OctFilled01:01:00
OctSubstantive Filled02:00:00

 

my hourscolumn is formatted as below

 

  • HI Dougers1 ,

    create the  measure below. Replace"TimeCalc" with your table name. 

    total time (hours and mins) = 
    IF(SELECTEDVALUE(TimeCalc[Status]) ="Substantive Filled", 
        FORMAT( SUM(TimeCalc[Hours]),"HH:MM"),
        blank()
    )

     If this doesn't resolve the issue, please provide a sample output.

     

6 Replies

  • adudani's avatar
    adudani
    Icon for Memorable Member rankMemorable Member

    HI Dougers1 ,

    create the  measure below. Replace"TimeCalc" with your table name. 

    total time (hours and mins) = 
    IF(SELECTEDVALUE(TimeCalc[Status]) ="Substantive Filled", 
        FORMAT( SUM(TimeCalc[Hours]),"HH:MM"),
        blank()
    )

     If this doesn't resolve the issue, please provide a sample output.

     

    • Dougers1's avatar
      Dougers1
      Frequent Visitor

      this is bringing me back wrong sum - its saying person A has worked 6hr 35 mins  for oct   - thats not correct answer should be 116hrs:15 mins

      • Dougers1's avatar
        Dougers1
        Frequent Visitor

        i added this   but it not adding them up correct sometimes it is but  other times it saying 32 hrs when it only 8

         

        Duration Hour Minute =
        //Find hour of time
        VAR _Hour = HOUR( SELECTEDVALUE( Interpreting[Hours] ) )
        //Find minute as proportion of hour
        VAR _Minute = DIVIDE(MINUTE( SELECTEDVALUE( Interpreting[Hours] ) ), 60, 0 )
        //Add together
        VAR _Result = _Hour + _Minute

        RETURN
        _Result
         
        then 
         
        Duration Sum v2 = SUMX( Interpreting, Interpreting[Duration Hour Minute] )
         but it bringing back differnt sums??

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Dougers1,

     

    You can create a measure as follows.

     

     

     

    total hours = CALCULATE(SUM('Table'[Hours]),FILTER('Table', 'Table'[Status] = "Substantive Filled"))

     

     

     

     

    Is this the result you expect?

     

    Best Regards,

    Yuliax

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.