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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Scaffnull
Helper I
Helper I

Calculate hours from count of days in month

Hi,

I have total hours of work for each month this year. I would like to create a formula to have -

Total Hours / CountDaysInMonth / 12.

 

So let's say I have 3000 hours in January, I'd like to have a way to calculate it - 3000 / 31 / 12.

 

Just having a hard time figuring out how I should have it count the days of the month. I have a Date table that is connected in the Model that has Month Name and DayInWeek.

 

Thanks for any help!

1 ACCEPTED SOLUTION
PaulOlding
Solution Sage
Solution Sage

Hi @Scaffnull 

You could add a new column to the date table to store number of days in the month.

Here's some DAX to do that.  You could do it in Power Query / M if you prefer.

Days in Month = 
VAR _Month = MONTH('Date'[Date])
VAR _Year = YEAR('Date'[Date])
VAR _Result = 
CALCULATE(
    DAY(MAX('Date'[Date])),
    FILTER('Date',
        MONTH('Date'[Date]) = _Month && YEAR('Date'[Date]) = _Year
    )
)
RETURN
    _Result

 

View solution in original post

3 REPLIES 3
PaulOlding
Solution Sage
Solution Sage

Hi @Scaffnull 

You could add a new column to the date table to store number of days in the month.

Here's some DAX to do that.  You could do it in Power Query / M if you prefer.

Days in Month = 
VAR _Month = MONTH('Date'[Date])
VAR _Year = YEAR('Date'[Date])
VAR _Result = 
CALCULATE(
    DAY(MAX('Date'[Date])),
    FILTER('Date',
        MONTH('Date'[Date]) = _Month && YEAR('Date'[Date]) = _Year
    )
)
RETURN
    _Result

 

@PaulOlding It solved it. It didn't work on my data table, but for the date table it worked like a charm. I had a month column in my data table so I just created a new column in my data table and made it related to the "Days in Month" column. Thanks again!

@PaulOlding Awesome! I will try this out. Thanks for your input.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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