Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hi @amitchandak , I hope you can help me here.
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:
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)
))
Solved! Go to Solution.
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?
Thanks.
@kulpowerbi
Did you solved? I have checked the pbix and see no problem with slicers and visuals.
Paul Zheng _ Community Support Team
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?
Thanks.
@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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 57 | |
| 33 | |
| 33 | |
| 18 | |
| 16 |
| User | Count |
|---|---|
| 68 | |
| 67 | |
| 45 | |
| 30 | |
| 28 |