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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Selded
Helper III
Helper III

Days in Current Month

Hello All,

 

I want to return the number of days in July and I used the measure below measure. It returns 30 days instead of 31 days.

 

Days_In_Current_Month = DAY(ENDOFMONTH('Date'[Date]))
 
 

ResultsResults

Regards
 
1 ACCEPTED SOLUTION
AntrikshSharma
Super User
Super User

If you meant currently selected month then you can use

Days in current month =
COUNTROWS ( VALUES ( Dates[Date] ) )

or

Days in current month = DISTINCTCOUNT( Dates[Date] )

 if you meant in July 2020 then

Days in current month =
COUNTROWS (
    FILTER (
        Dates,
        Dates[Month Number] = MONTH ( TODAY () )
            && Dates[Calendar Year Number] = YEAR ( TODAY () )
    )
)

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@Selded , Try

 

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

if it is a measure
Days_In_Current_Month = DAY(today(),0))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
AntrikshSharma
Super User
Super User

If you meant currently selected month then you can use

Days in current month =
COUNTROWS ( VALUES ( Dates[Date] ) )

or

Days in current month = DISTINCTCOUNT( Dates[Date] )

 if you meant in July 2020 then

Days in current month =
COUNTROWS (
    FILTER (
        Dates,
        Dates[Month Number] = MONTH ( TODAY () )
            && Dates[Calendar Year Number] = YEAR ( TODAY () )
    )
)

@AntrikshSharma 

 

I am looking for a measure that will return the number of days in any current month. July is now the current month so it should return 31 days, Next month is August , when we enter August it shoukd return 31 day as well. 

 

i tried your suggestions, measure number 3 returned blank days. please explain what the year number is suppose to stand for , as i dont have that in my date table.

A snip of my date table below and also the measure below.

 

Selded_0-1594638407742.png

 

Selded_1-1594638513672.png

 

thank you

 

Calendar year number is just year like 2020, 2019 etc do you have the dates for 2020 in your table?

@AntrikshSharma 

yes i do.

Hi @Selded ,

 

The above solution looks correct.

 

However you can try,

 

Create a Calculated Column in your Date Table.

 

YearMonthnumber = FORMAT ( Dates[Date],"YYYYM")

 

Then create a measure

 

Days in current Month =
VAR _month =
    MONTH (
        TODAY ()
    )
VAR _year =
    YEAR (
        TODAY ()
    )
RETURN
    COUNTROWS (
        FILTER (
            ALL ( Dates ),
            Dates[YearMonthnumber]
                = CONCATENATE (
                    _year,
                    _month
                )
        )
    )

 

 

1.jpg

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

 

@harshnathani 

 

this worked correctly.

 

Thank you

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.

August 2025 community update carousel

Fabric Community Update - August 2025

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