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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

How to format a date calculation to give a number / calculate numbers of days based on slicer

Hello,

 

I am trying with this formula to create a calculation of the days based on the selection in a date slicer (so the count of actual days e.g. if the slicer is set to show the last 60 days, the measure will return the number 60, which I can then use in other calculations). However, I am stuck and nothing is working. I know there is a lot on this topic available, but I have not been able to use any of that info yet.
This is the dax measure:
 
DataScore_13-count_days_slicer =
 
VAR FirstDay = CALCULATE(
MIN(DIM_DATE_D1[Date]),
ALLSELECTED(DIM_DATE_D1[Date])
)
VAR LastDay = CALCULATE(
MAX(DIM_DATE_D1[Date]),
ALLSELECTED(DIM_DATE_D1[Date])
)
RETURN

DATESBETWEEN(DIM_DATE_D1[Date],FirstDay,LastDay)
 
The DIM_DATE_D1[Date] is the date table I am using (corporate date table)
 
What am I doing wrong?
 
So just to be clear, I need a measure that gives me the amount of dates, based on the date slicer settings on my report pages. 
 
Cheers,
Carsten
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 
DATESBETWEEN returns a table. My understanding that you want to return the number of selected days. You can achieve that by returning

RETURN
DATEDIFF ( FirstDay, LastDay, DAY )

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @tamerj1 

 

Thanks a lot, it is clear and the dateiff funtion works, brilliant. Very much appreciated. And I also inderstand datesbetween much better now. 

 

Cheers,

Carsten

tamerj1
Super User
Super User

Hi @Anonymous 
DATESBETWEEN returns a table. My understanding that you want to return the number of selected days. You can achieve that by returning

RETURN
DATEDIFF ( FirstDay, LastDay, DAY )

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.