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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
tavolo89
Frequent Visitor

DATESBETWEEN is not working with min and max dates

I am trying to select a date (or several dates) in my slicer, and then use this to calculate a range of dates from 5 days prior to the earliest date selected to the max date in the slicer. For example, selecting 10th Feb in the slicer should give me a date range from 5th Feb to 10th Feb.

 

datesbetween - slicer min max.png

 

I've created two calculated columns for these:

 
MinDatePeriodMX = CALCULATE(min('Period A'[Day_Date])-5)
MaxDatePeriodMX = CALCULATE(max('Period A'[Day_Date]))
 
They seem to work as expected.
 
However, I can't use them in conjunction with this formula:
 
# Users - L13W MX = CALCULATE([# Users], DATESBETWEEN('Period A'[Day_Date], [MinDatePeriodMX], [MaxDatePeriodMX]))
 
Instead of returning the # Users measure for only the dats in red below, it returns either only the date(s) in the slicer or if i disable interactions from the slicer, then it returns all dates there is data for.
tavolo89_0-1677929277550.png

 

 

 
 
 

I only want the range of dates in the red box above. How do I achieve this?



If I change the formula to "hardcode" the dates then it does work as expected:
 
# Users - L13W = CALCULATE([# Users], DATESBETWEEN('Period A'[Day_Date], "2023-02-05", "2023-02-10"))
 
tavolo89_0-1677930284280.png

Which makes me think that I'm missing some context somewhere. But I can't for the life of me work out where.

3 REPLIES 3
andhiii079845
Super User
Super User

I build the report with your information:

andhiii079845_0-1678173394834.png

andhiii079845_1-1678173439756.png

 

Important: In the table is the table date column and the slicer the date from dimDate column!

 

Measure = 
CALCULATE([User],DATESBETWEEN(dimDate[Date],[MinDatePeriodMX],[MaxDatePeriodMX]))
 




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

Proud to be a Super User!




tavolo89
Frequent Visitor

Thanks for the reply!

 

'Period A'[Day_Date] is my date dimension table.

andhiii079845
Super User
Super User

You use directly the column 'Period A'[Day_Date] in the slicer and table? This will not work, because you choose a value from 'Period A'[Day_Date] via slicer and this also change the matrix. It is the same column. I think you have to use a separate dimtable for dates. You put this dim table date in the slicer.  





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

Proud to be a Super User!




Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.