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