Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Dougers1
Frequent Visitor

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

Dougers1_0-1701101959627.png

 

1 ACCEPTED SOLUTION
adudani
Super User
Super User

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.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

View solution in original post

6 REPLIES 6
v-xuxinyi-msft
Community Support
Community Support

Hi @Dougers1,

 

You can create a measure as follows.

 

 

 

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

 

 

 

 

vxuxinyimsft_0-1701151990274.png

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.

bringing back wrong sum ?

adudani
Super User
Super User

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.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

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

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??
Dougers1_0-1701613129482.png

 

The VAR result is adding hour and minutes as integer value, not a time value to which works display it in hh:mm format

 

Would you be able to share the pbix/raw data masking sensitive information?

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors