Dynamic count days in month and days passed

I am trying to develop a measure that will return what percentage of days have passed in a selected month. For example, today is Sep 11 so 11 days have passed in the month. Since Sep has 30 days this means that 37% of the days have passed.

I imagine that I have to first write a measure to calculate each Days in Month. I found the attached DAX in the forum. I am not finding a solution for the second part. How many days have passed in the current month.

Hi @jmolina,

You can use the DAY() function for that, give this a go:

% days passed in CM =
VAR CurrDay = DAY( TODAY() )
VAR DaysInMonth = DAY(EOMONTH( TODAY(), 0 ))
VAR PCT = DIVIDE( CurrDay, DaysInMonth )
RETURN

PCT
1 Like

@Melissa your solution worked perfectly, Thanks!

However, the consumer now wants the measure to dynamically reflect the selected month in the page. I have attached a screenshot.

Hi @jmolina,

Two questions for you:

  1. How do you identify the CurrentDay with only a month slicer on the page?
  2. Is the Date range fixed to a single year?

You could try something like:
DAY( EOMONTH( SELECTEDVALUE( Dates[StartOfMonth] ), 0 ))