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
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
Community Champion
Community Champion

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))

AntrikshSharma
Community Champion
Community Champion

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
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.

Top Solution Authors