Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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

Results

Regards
 
  • 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 () )
        )
    )

7 Replies

  • AntrikshSharma's avatar
    AntrikshSharma
    Icon for Community Champion rankCommunity 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 () )
        )
    )
    • Anonymous's avatar
      Anonymous
      Not applicable

      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.

       

       

       

      thank you

       

      • AntrikshSharma's avatar
        AntrikshSharma
        Icon for Community Champion rankCommunity Champion
        Calendar year number is just year like 2020, 2019 etc do you have the dates for 2020 in your table?
  • Anonymous , Try

     

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

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