Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Using hh:mm:ss format on Power BI charts

Hey I seem to be having an issue using hh:mm:ss format measures in Power BI charts. (Bar, line, area, etc) I try to drag the measure to any of the axis spots (x, y, line) and nothing happens, it wont drop that measure into the axis spot. Even if I go with table, bring the field in and then switch visual to a chart it puts the field in the "Tooltips" section.

 

The field is a measure and this is the code.  Any ideas? I have that measure formatted as (h:mm:ss) also tried different variations of times. Tried dividing by 1 or multipying by 86400. Neither worked. 

 

*AvgSpeedOfAnswer = TIME(0,0,CALCULATE(SUM('Interactions'[QueueTime_s]),filter('Queues','Queues'[IsInbound]=1),FILTER('Interactions','Interactions'[IsAnswered]=1))/SUM('Interactions'[IsAnswered]))

3 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the info.  So do I just create a new measure using this code? This seems like it wouldnt work based on the calculation I am using in my measure. I am still learning dax, so excuse any dumb questions. 

       

      *AvgSpeedOfAnswer = TIME(0,0,CALCULATE(SUM('Interactions'[QueueTime_s]),filter('Queues','Queues'[IsInbound]=1),FILTER('Interactions','Interactions'[IsAnswered]=1))/SUM('Interactions'[IsAnswered]))

       

      Chelsie Eiden's Duration = 
      // Duration formatting 
      // * @konstatinos 1/25/2016
      // * Given a number of seconds, returns a format of "hh:mm:ss"
      //
      // We start with a duration in number of seconds
      VAR Duration = SUM([Duration])
      // There are 3,600 seconds in an hour
      VAR Hours = INT ( Duration / 3600)
      // There are 60 seconds in a minute
      VAR Minutes = INT ( MOD( Duration - ( Hours * 3600 ),3600 ) / 60)
      // Remaining seconds are the remainder of the seconds divided by 60 after subtracting out the hours 
      VAR Seconds = ROUNDUP(MOD ( MOD( Duration - ( Hours * 3600 ),3600 ), 60 ),0) // We round up here to get a whole number
      RETURN
      // We put the hours, minutes and seconds into the proper "place"
      Hours * 10000 + Minutes * 100 + Seconds

       

      • Greg_Deckler's avatar
        Greg_Deckler
        Icon for Community Champion rankCommunity Champion

        Anonymous The key takeaway is that you need to get your duration into the appropriate form and then apply a custom format string.