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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jesly_ajin
Helper III
Helper III

Count the days between the slicer dates in Power BI excluding weekends

Count the days between the slicer dates in Power BI excluding weekends

 

1 ACCEPTED SOLUTION

Hi, @jesly_ajin 

I am not quite sure if the below measure suits your requirement because it was quite difficult for me to understand your data model.

Please try to test it on the blank page.

On the blank page, create a slicer that uses a calendar-table, that is disconnected to the table.

 

weekdayscount(new) =
VAR newtable =
ADDCOLUMNS (
InEightProjEquipmentStagingTable,
"@dayscount",
CALCULATE (
COUNTROWS ( 'calendar' ),
DATESBETWEEN (
'calendar'[Calendar_date],
SELECTEDVALUE ( InEightProjEquipmentStagingTable[FROMDATE] ),
SELECTEDVALUE ( InEightProjEquipmentStagingTable[TODATE] )
),
'calendar'[Week_day_name] <> "Saturday"
&& 'calendar'[Week_day_name] <> "Sunday"
)
)
RETURN
SUMX ( newtable, [@dayscount] )

 

If the above is not working, please try to change the [FROMDATE] and [TODATE] columns to Date Type, not date & time type.

I hope it works.

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

8 REPLIES 8
Jihwan_Kim
Super User
Super User

Hi, @jesly_ajin 

I am not sure about how your data model look like, but in my cases, I generally have custom date table, and I normally write below DAX measure.

I have DayOfWeek column in my date-table. (Sunday = 0, Saturday = 6)

 

count days between slicer dates excluding weekends =
CALCULATE (
COUNTROWS ( dates ),
FILTER ( ALLSELECTED ( dates ), dates[DayOfWeek] <> 0 && dates[DayOfWeek] <> 6 )
)
 
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

@Jihwan_Kim , 

Thanks for response.

 

I have 2 measures [CalcFromDate] & [CalcToDate] :-

CalcFromDate = IF(MIN(InEightProjEquipmentStagingTable[FROMDATE])<=[MinSelectedDate],[MinSelectedDate], MIN(InEightProjEquipmentStagingTable[FROMDATE]))
 
CalcToDate = IF(MAX(InEightProjEquipmentStagingTable[TODATE])>=[MaxSelectedDate],[MaxSelectedDate], MAX(InEightProjEquipmentStagingTable[TODATE]))

 

ActualAllocEqDays =
SUMX(InEightProjEquipmentStagingTable,
IF(DATEDIFF([CalcFromDate],[CalcToDate],DAY)+1<=0,0,DATEDIFF([CalcFromDate],[CalcToDate],DAY)+1))
 
Now, in ActualAllocEqDays, it takes all the days including weekends.
I need the count of days excluding weekend.
 
Please help.

Hi, @jesly_ajin 

I am not quite sure if the below measure suits your requirement because it was quite difficult for me to understand your data model.

Please try to test it on the blank page.

On the blank page, create a slicer that uses a calendar-table, that is disconnected to the table.

 

weekdayscount(new) =
VAR newtable =
ADDCOLUMNS (
InEightProjEquipmentStagingTable,
"@dayscount",
CALCULATE (
COUNTROWS ( 'calendar' ),
DATESBETWEEN (
'calendar'[Calendar_date],
SELECTEDVALUE ( InEightProjEquipmentStagingTable[FROMDATE] ),
SELECTEDVALUE ( InEightProjEquipmentStagingTable[TODATE] )
),
'calendar'[Week_day_name] <> "Saturday"
&& 'calendar'[Week_day_name] <> "Sunday"
)
)
RETURN
SUMX ( newtable, [@dayscount] )

 

If the above is not working, please try to change the [FROMDATE] and [TODATE] columns to Date Type, not date & time type.

I hope it works.

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi, @jesly_ajin 

Thank you for your question.

If it is OK with you, can I see your sample pbix file? 

It is quite difficult for me to come up with a desirable solution without seeing the data model.

By only seeing the first two measures, I think those are referencing the date-table to calculate the days-count between the slicer. -> is it not connected?

If it is not connected, I think it is not so easy to put the condition (noweeken) that comes from the date-table.

If it is OK, please share the sample pbix file, then I can try to solve it.

Thank you very much.

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

it is not connected. It is like calculating the difference between 2 independent dates.

Kindly send me your email id - i can do the wetransfer of the file to you.

I sent my email address via message.

please check your message inbox.

Thank you.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thanks a lot for the help and support sir.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors