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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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