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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
kulpowerbi
Helper I
Helper I

DateBetween using date slicer

Hi @amitchandak , I hope you can help me here.

FromToDateRange.JPG

I am looking for a solution where users can select FromDate that will be crafted usng (year, month,quarter all three using different slicer) and the same is for ToDate using slicer.
FromDate and ToDate both are separate tables and having a date field. Not connected with any tables in the model.

I am using this slicer to generate the date range for DatesBetween Function. but somehow when months are selected. it's not working. for year selection it's working.

Model: 

Model.JPG

 

The PowerBi file is in OneDrive attached. Thank you for your help in advance.

Selected_FromTO = 

Var FromMonth = MIN('From'[Date].[MonthNo])

var ToMonth = Max('To'[Date].[MonthNo])

var FromYear = MIN('From'[Date].[Year])

var ToYear = Max('To'[Date].[Year])

var MonthRange= FromMonth&"_"& ToMonth

var YearRange = FromYear&"_"& ToYear

var MonthYearRange = MonthRange &"___"&YearRange

return CALCULATE(SUM(Table1[sales]),

DATESBETWEEN(Table1[date].[Date],DATE(FromYear,FromMonth,1),DATE(ToYear,ToMonth,1)

))
1 ACCEPTED SOLUTION
kulpowerbi
Helper I
Helper I

Hi @amitchandak  Thanks for the quick response. The solution is working for Year and Month Slicer but not working on Quarter Selection. Could you please look into this?

 

kulpowerbi_1-1624264163195.png

 

 

Thanks.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@kulpowerbi 
Did you solved? I have checked the pbix and see no problem with slicers and visuals.

 

Paul Zheng _ Community Support Team

kulpowerbi
Helper I
Helper I

Hi @amitchandak  Thanks for the quick response. The solution is working for Year and Month Slicer but not working on Quarter Selection. Could you please look into this?

 

kulpowerbi_1-1624264163195.png

 

 

Thanks.

amitchandak
Super User
Super User

@kulpowerbi , as these are date Min and max

 

Selected_FromTO =
Var _Min = MINX(allselected('From'), 'From'[Date])
Var _Max = MAXX(allselected('To'), 'To'[Date])
return

CALCULATE(SUM(Table1[sales]), filter(Table1, Table1[date]>=_min && Table1[date]<=_max))

 

Also, I would suggest you create column for year, month , day etc in your date tables 

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

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.