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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to count number of days selected from SLICER

Hi,

 

I want to count number of days regardless of checking that if data is in database or not. All I want is when user select date range from slicer either days or months or years. It should count the number of days including weekends and just display number of days.

 

For example :

 

Hunain_1-1618364503750.png

Number of days = 3

 

Hunain_0-1618364458846.png

Number of days = 3 * 7 = 21 days

 

At the moment I get count of days for which data exist in database. Whereas I want to count total number of days selected even if data is not present in database. Thanks

6 REPLIES 6
amitchandak
Super User
Super User

@Anonymous , On you slicer column, try a measure like

 

measure =
var _max = maxx(ALLSELECTED('Date'),'Date'[Date])
var _min = minx(ALLSELECTED('Date'),'Date'[Date])
return
datediff(_min,_max,day)+1

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks! This solution worked for me. I had problems with the function "AVERAGEX(VALUES ....", so I replaced it with your suggestion and it worked.

Anonymous
Not applicable

It's not working when I use the below selection I get Number of days 1 instead of 3 :

 

Hunain_0-1618371087549.png

 

Anonymous
Not applicable

Because I don't have data in database for date 13/04/2021 and 14/04/2021. But I want to count number of days regardless of data in database. 

@Anonymous , we do not have a way to know other parameters from the relative date slicer. So if dates are not present, I doubt of a way I know.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Please see below screenshots :

Showing that it brings the max date from database instead of getting it from slicer.

 

Hunain_0-1618371641236.png

Hunain_1-1618371661392.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.