Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi everybody
I have been looking for the solution before coming to you. How do I get the 2 dates selected ina date slicer. The dates to be returned should not be the ones in the table, but the selected ones. I explain. Let's say I have sales dates in a table ranging from 1 Jan 21 to 25 June 21. ( All products)The slicer shows these dates by default. Now I apply a filter say on Product ( bicycles) -
In the table the dates can be 10 Feb 21 to 18 March 21 ( these are the dates between, I haves sales of bicycles) and will be displayed if I choose in the Date Slicer Dates Date From 9 Feb 21 to 30 March 21. I am looking at how to get the Slicer dates ( 9 Feb 21 and 30 March 21) and not the Min and Max Dates returned ( 10 Feb 21 and 18 March 21)
Thanks to help me.
Solved! Go to Solution.
@Jaweed
It cannot be done with a single table. you need to create a date table and create a relationship. The measure to get the slicer date will be as follows. I attached a PBIX file.
Start Date =
CALCULATE(
MIN('Table'[Date]),
ALLEXCEPT('Table',Dates[Date])
)
---------------------------------------------
End Date =
CALCULATE(
MAX('Table'[Date]),
ALLEXCEPT('Table',Dates[Date])
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@Jaweed
It cannot be done with a single table. you need to create a date table and create a relationship. The measure to get the slicer date will be as follows. I attached a PBIX file.
Start Date =
CALCULATE(
MIN('Table'[Date]),
ALLEXCEPT('Table',Dates[Date])
)
---------------------------------------------
End Date =
CALCULATE(
MAX('Table'[Date]),
ALLEXCEPT('Table',Dates[Date])
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
HiFowmy
After I do test, it does not give the sekected values.
@Jaweed
You can use as the measure as follows
Start Date = MIN('Dates'[Date])
---------------------------------------------
End Date = MAX('Dates'[Date])
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@Fowmy I figured out the key to making this work was using the Date Table dates for the slicer vs. using the Created Date from my fact table. Once I did that, everything worked like you said. THANK YOU!
Hi Fowmy
Thanks a lot. The Date filtering is on Date Table which we will have to create, may be for dates up to 2024. Is there a way to set the Start and End Date in the slicer as the MIN and Max dates which are in the product file rather than the MIN and Max on the Date file created? I appreciate your valuable advice. Sorry for inconvenience, I am just stuck with his.
@Jaweed I, too, had my date table extended to 2025. I ended up just tightening it up to the current year ( DATE(YEAR(TODAY()),12,31) ) so my default date range was 1/1/20 through the end of this year.
Unless you have a specific reason to extend your date table beyond this year (maybe you have projected sales), I'd suggest keeping it tight.
Thank you very much Fowmy
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
93 | |
75 | |
62 | |
50 |
User | Count |
---|---|
147 | |
107 | |
105 | |
87 | |
61 |