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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Urgent Help to Calculate Percentage of Date Remaining in a Month dynamically

Hello,

 

I am trying to add a rotating tile which displays Number of days in current month remaining and i got it to work using

Days Left in Month = INT(EOMONTH(TODAY(), 0) - TODAY())
And on the other side i need to display % of days remaining in current month. I tried to do this using 
Workdays Passed in Month AS Percent =
    VAR WorkdaysLeftinMonth = COUNTROWS(
    FILTER(
        CALENDAR(
            TODAY(),
            EOMONTH(TODAY(), 0)
        ),
        WEEKDAY([Date], 1) < 7
    )
)
VAR TotalWorkDaysInMonth = COUNTROWS(
            FILTER(
                CALENDAR(
                    DATE(MONTH(TODAY()),1,1),
                    DATE(MONTH(TODAY())+1,1,1)-1
                ),
                WEEKDAY([Date], 1) < 7
            )
        )   
        
RETURN DIVIDE(WorkdaysLeftinMonth,TotalWorkDaysInMonth,0)
 
It shows 7% remaining which is wrong. Need to fix this ASAP. My calendar table is
 
Dates_Dim =
GENERATE (
CALENDAR ( DATE ( Year(TODAY()), 0, 1 ), DATE ( Year(TODAY()),MONTH(TODAY()),31)),
VAR currentDay = [Date]
VAR day = DAY( currentDay )
VAR month = MONTH ( currentDay )
VAR year = YEAR ( currentDay ) var Month_name = FORMAT([Date], "MMM")
RETURN ROW (
"day", day,
"month", month, "Month_name",Month_name,
"year", year )
)
 
By this i limit to current Month. Now if i select September i need the rotating tile to display 0 as number of days left because september is over and 100% as % of days left.
 
Thanks
12 REPLIES 12
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Is this problem sloved? 
If it is sloved, could you kindly accept it as a solution to close this case?
If not, please let me know.
 
Best Regards
Maggie
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

If Watsky's reply solve your problem, please accept it as a solution so others may find it quickly.

If not, please refer to my solution.

Create measures

TODAY = TODAY()

TOTAL DAYS THIS MONTH = CALCULATE(COUNT(Dates_Dim[day]),FILTER(ALL(Dates_Dim),Dates_Dim[year]=YEAR([TODAY])&&Dates_Dim[month]=MONTH([TODAY])))

REMAING DAYS = CALCULATE(COUNT(Dates_Dim[day]),FILTER(ALL(Dates_Dim),Dates_Dim[year]=YEAR([TODAY])&&Dates_Dim[month]=MONTH([TODAY])&&Dates_Dim[Date]>[TODAY]))

% = [REMAING DAYS]/[TOTAL DAYS THIS MONTH]

Capture8.JPG

If we change [Today] measure as below

TODAY = DATE(2019,10,7)

Capture9.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Watsky
Solution Sage
Solution Sage

See if this works:

 

First add a new column to your Date table:

WorkDay = IF(WEEKDAY(Dates_Dim[Date],2)<6,1,0)

Then try this measure:

Workdays Passed in Month AS Percent = 
   
VAR ThisToday = TODAY()
VAR ThisMonthStart = DATE(year(ThisToday),MONTH(ThisToday),1)
VAR EOM = EOMONTH(ThisMonthStart,0)

VAR BIZWEEK = MOD(
    5 + WEEKDAY(
        TODAY() + 1) - 
            WEEKDAY(EOMONTH(TODAY(),0)-1),
            5)

VAR TotalWorkDaysInMonth =  CALCULATE(
    SUM(Dates_Dim[Workdday])
    ,ALL(Dates_Dim)
, DATESBETWEEN(Dates_Dim[Date],ThisMonthStart,EOM)

)
RETURN
    DIVIDE(TotalWorkDaysInMonth - BIZWEEK,TotalWorkDaysInMonth)

This returned 83% for me. Let me know if that worked for you.


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

Anonymous
Not applicable

@Watsky 

 

I tweaked yours 

 

First add a new column to your Date table:

WorkDay = IF(WEEKDAY(Dates_Dim[Date],1)<8,1,0)

Then try this measure:

Workdays Passed in Month AS Percent = 
   
VAR ThisToday = TODAY()
VAR ThisMonthStart = DATE(year(ThisToday),MONTH(ThisToday),1)
VAR EOM = EOMONTH(ThisMonthStart,0)

VAR BIZWEEK = MOD(
    7 + WEEKDAY(
        TODAY() + 1) - 
            WEEKDAY(EOMONTH(TODAY(),0)-1),
            7)

VAR TotalWorkDaysInMonth =  CALCULATE(
    SUM(Dates_Dim[Workdday])
    ,ALL(Dates_Dim)
, DATESBETWEEN(Dates_Dim[Date],ThisMonthStart,EOM)

)
RETURN
    DIVIDE(TotalWorkDaysInMonth - BIZWEEK,TotalWorkDaysInMonth)

It worked. But when i selected September it still shows values for current month. For september it should say days remaining as 0 and % as 100%

Anonymous
Not applicable

Any help on this?

@Anonymous  I changed all the Today() to the date range instead. Give this a shot.

Workdays Passed in Month AS Percent = 
   
VAR ThisToday = TODAY()
VAR ThisMonthStart = STARTOFMONTH(Dates_Dim[Date])
VAR ThisMonthEnd = ENDOFMONTH(Dates_Dim[Date])

VAR BIZWEEK = MOD(
    5 + WEEKDAY(
        ThisMonthStart+ 1,1) - 
            WEEKDAY(ThisMonthEnd,1)-1,
            5)

VAR TotalWorkDaysInMonth =  CALCULATE(
    SUM(Dates_Dim[Workdday])
    ,ALL(Dates_Dim)
, DATESBETWEEN(Dates_Dim[Date],ThisMonthStart,ThisMonthEnd)

)
RETURN
   IF(MONTH(ThisMonthEnd)=MONTH(ThisToday), DIVIDE(TotalWorkDaysInMonth-BIZWEEK,TotalWorkDaysInMonth),1)

Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

Anonymous
Not applicable

@Watsky  I used below and it is returning 84%. Value should be 77.4%

 

% Workdays Passed in Month =
 
VAR ThisToday = TODAY()
VAR ThisMonthStart = STARTOFMONTH('Dates_Dim'[Date])
VAR ThisMonthEnd = ENDOFMONTH('Dates_Dim'[Date])

VAR BIZWEEK = MOD(
7 + WEEKDAY(
ThisMonthStart+ 1,1) -
WEEKDAY(ThisMonthEnd,1)-1,
7)

VAR TotalWorkDaysInMonth = CALCULATE(
SUM('Dates_Dim'[WorkDay])
,ALL('Dates_Dim')
, DATESBETWEEN('Dates_Dim'[Date],ThisMonthStart,ThisMonthEnd)

)
RETURN
IF(MONTH(ThisMonthEnd)=MONTH(ThisToday), DIVIDE(TotalWorkDaysInMonth-BIZWEEK,TotalWorkDaysInMonth),1)
 
Please tell where I am going wrong.

Not sure how you get 77.4% the best I could come up with is 77.27%

 

% Workdays Passed in Month = 
 
VAR ThisToday = TODAY()
VAR ThisMonthStart = STARTOFMONTH('Dates_Dim'[Date])
VAR ThisMonthEnd = ENDOFMONTH('Dates_Dim'[Date])

VAR BIZWEEK = MOD(
7 + WEEKDAY(
ThisMonthStart,1) -
WEEKDAY(ThisMonthEnd,1),
7)

VAR TotalWorkDaysInMonth = CALCULATE(
SUM(Dates_Dim[Workdday])
,ALL('Dates_Dim')
, DATESBETWEEN('Dates_Dim'[Date],(ThisMonthStart),(ThisMonthEnd)-1)

)
RETURN
IF(MONTH(ThisMonthEnd)=MONTH(ThisToday), DIVIDE((TotalWorkDaysInMonth-BIZWEEK),TotalWorkDaysInMonth),1)

Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

Anonymous
Not applicable

@Watsky  Thanks for response. But even this returned 83%

I'm not sure why but yours is returning different than mine. 

image.png

 


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

@Anonymous  I'm still looking in to it.


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

Anonymous
Not applicable

@Watsky 

 

Thanks! I am looking for calendar days and not working days. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.