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

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.

Reply
Jaweed
Helper III
Helper III

Retrieving 2 selected dates in Date Slicer

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.

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@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])
)

Fowmy_0-1625082164831.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

7 REPLIES 7
Fowmy
Super User
Super User

@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])
)

Fowmy_0-1625082164831.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


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_0-1625085032770.png

 

@Jaweed 

You can use as the measure as follows

 

 

Start Date =  MIN('Dates'[Date])
---------------------------------------------
End Date =   MAX('Dates'[Date])

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

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

Anonymous
Not applicable

@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

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.