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

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

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
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.