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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

How to calculate percentage based on Date range slicer


Hi! I'm tring to calculate percentage of month based on Date range slicer on the dashboard.

Such as ;
November = 30 days

Date on slicer = 11/01/2022-11/15/2022
Percentage = 50%

If date range on slicer is 12/01/2022 - 12/19/2022 , then percentage = 61.29%
so this percentafe should change as Date slicer.

I've created Date table and add measure to count date of every month, but still cannot count date as slicer.
How should I do?




1 ACCEPTED SOLUTION
Uzi2019
Super User
Super User

Hi @Anonymous 
Please do the following steps:  2 seperate measures


1) Create last date measure (It will calculate last day of date selected like 30/31)

Edate_day(EOMONTH(MAX('Calendar'[Date]),0))
 
2) Create new measure for % calculation ( It will count the no of days between 2 selected date range)
         Datesum =
           Var Total =DATEDIFF(MIN('Calendar'[Date]),MAX('Calendar'[Date]),DAY)+1
           Return (Total/[Edate_])
 

Check the result:
Uzi2019_0-1697625716115.png

 

I hope I answered your question please give kudos and accept it as a solution!
Thanks

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

View solution in original post

8 REPLIES 8
Uzi2019
Super User
Super User

Hi @Anonymous 
Please do the following steps:  2 seperate measures


1) Create last date measure (It will calculate last day of date selected like 30/31)

Edate_day(EOMONTH(MAX('Calendar'[Date]),0))
 
2) Create new measure for % calculation ( It will count the no of days between 2 selected date range)
         Datesum =
           Var Total =DATEDIFF(MIN('Calendar'[Date]),MAX('Calendar'[Date]),DAY)+1
           Return (Total/[Edate_])
 

Check the result:
Uzi2019_0-1697625716115.png

 

I hope I answered your question please give kudos and accept it as a solution!
Thanks

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
Anonymous
Not applicable

Thank you @Uzi2019 , It's work!

Hi @Anonymous 
Did you try my solution???

If it helps please give kudos and accept it as a solution!

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
rubayatyasmin
Super User
Super User

Hi, @Anonymous 

 

Lets break down the solution into parts. 

 

For days: 

 

Calculate the days selected in the date range

 

TotalDays = COUNTROWS(DATESBETWEEN('Date Table'[Date], MIN('Date Table'[Date]), MAX('Date Table'[Date])))

 

calculate the number Of days in the month for the start date selected in a range.

 

DaysInMonth = CALCULATE(
COUNTROWS('Date Table'),
FILTER(
'Date Table',
MONTH('Date Table'[Date]) = MONTH(MIN('Date Table'[Date])) &&
YEAR('Date Table'[Date]) = YEAR(MIN('Date Table'[Date]))
)
)

 

 

calculate the percentage:

 

PercentageOfMonth = DIVIDE([TotalDays], [DaysInMonth])

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Anonymous
Not applicable


HI! @rubayatyasmin thank you for your reply

but as this 
TotalDays = COUNTROWS(DATESBETWEEN('Date Table'[Date], MIN('Date Table'[Date]), MAX('Date Table'[Date])))

the result is still not change as date selected in a range. It's still count all date of the data, even I've only chosen 1 month.

Did you have any advice for this?

Thanks


can you provide a demo file?


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Anonymous
Not applicable


Sure

Hi @Anonymous 
Did u try my answer ???

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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