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
lsullivan6311
Helper III
Helper III

Calculate Days in Month based on Year/Month to add column to Dates table for use in other formulas

I need the total number of days in the month based on the Year/Month; for example,

Year/Month            MonthName              MonthNo         NoOfDays

2022/01                    January                           1                      31      

2022/02                    February                         2                      28

 

so that is the year was a leap year, February would have 29 days.  I will be using a Year/Month filter on visuals and a measure that will need the days in the month to calculate unit hours in that month.  I have the measure I need already, but I just need to update for the filtered number of days.

 

 

1 ACCEPTED SOLUTION
ppm1
Solution Sage
Solution Sage

You can use this expression in a calculated column, provided you have a column with a date value within the desired month.

 

DaysInMonth = DAY(EOMONTH('Date'[Date], 0))

 
Or in a measure, you can also put any expression that returns a date inside EOMONTH too.
 
Pat
 
Microsoft Employee

View solution in original post

1 REPLY 1
ppm1
Solution Sage
Solution Sage

You can use this expression in a calculated column, provided you have a column with a date value within the desired month.

 

DaysInMonth = DAY(EOMONTH('Date'[Date], 0))

 
Or in a measure, you can also put any expression that returns a date inside EOMONTH too.
 
Pat
 
Microsoft Employee

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.