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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
yaman123
Post Patron
Post Patron

Calculate Total Days, Hours, Minutes, Seconds in a Month

Hi,

 

Is there a way to show the total days, hours, minutes and seconds in a chosen month? I have a date table which is linked to my other tables. 

 

E.g if i select November 2021,Total Days = 30, Total Hours = 720, Total Minutes = 43200, Total Seconds = 2592000

 

Thanks

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @yaman123 ,

Here are the steps you can follow:

1. Create measure.

Measure =
var _select=SELECTEDVALUE('Table'[Date])
var _startday=EOMONTH(_select,-1)
var _endday=ENDOFMONTH('Table'[Date])
var _day=
DATEDIFF(_startday,_endday,DAY)
var _hour=
DATEDIFF(_startday,_endday,HOUR)
var _minute=
DATEDIFF(_startday,_endday,MINUTE)
var _second=
DATEDIFF(_startday,_endday,SECOND)
return
_day&""&"Days" &" "&  _hour&""&"Hours" &" "&  _minute&""&"Minutes" &" "&  _second&""&"Seconds"

2. Result:

vyangliumsft_0-1640052535891.png

 

Best Regards,

Liu Yang

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

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @yaman123 ,

Here are the steps you can follow:

1. Create measure.

Measure =
var _select=SELECTEDVALUE('Table'[Date])
var _startday=EOMONTH(_select,-1)
var _endday=ENDOFMONTH('Table'[Date])
var _day=
DATEDIFF(_startday,_endday,DAY)
var _hour=
DATEDIFF(_startday,_endday,HOUR)
var _minute=
DATEDIFF(_startday,_endday,MINUTE)
var _second=
DATEDIFF(_startday,_endday,SECOND)
return
_day&""&"Days" &" "&  _hour&""&"Hours" &" "&  _minute&""&"Minutes" &" "&  _second&""&"Seconds"

2. Result:

vyangliumsft_0-1640052535891.png

 

Best Regards,

Liu Yang

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

Samarth_18
Community Champion
Community Champion

Hi @yaman123 ,

Create a column for each with below code:-

Days:-

 

 

Days = 
var dayy = EOMONTH(Days_calculation[Column1],0)
return  DAY(dayy)

 

 

Hours:-

 

 

Hours = Days_calculation[Days] * 24

 

 

Minutes

 

 

Minutes = Days_calculation[Hours] * 60

 

 

Seconds

 

 

Seconds = Days_calculation[Minutes] * 60​

 

 

 

Now add month in a slicer and these columns in required visual you will get desired output.

 

Output:-

Samarth_18_1-1639587858552.png

 

Samarth_18_0-1639587848313.png

Thanks,
Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.