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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Dynamic end date slicer based on start date slicer selection

Hi,

I'm trying to have two slicers as start_date and end_date. I want to custom end_date list based on start_date slicer selection. 

I tried to create a end_date table by passing selectedvalue from start_date slicer like below but selectedvalue is returning null

 

end_date_table = 
var selected_start_date = SELECTEDVALUE(start_date_table[Start Date])
return 
ADDCOLUMNS(
    CALENDAR(format(selected_start_date, "YYYYMMDD"), DATE(2021,8,30)),
    "End Date", FORMAT([Date], "YYYY-MM-DD")
)

 

Error: Cannot convert value '' of type Text to type Date.

 

I tried to follow this solution by creating parameters still could't achieve the desired solution. 

https://community.powerbi.com/t5/Desktop/Passing-Parameters-in-measures/m-p/208276

 

Capture.PNG

 

 

pbix file link - removed

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Please review the solution in the following thread and check whether that is what you want.

Dependent date slicers

1. Create two calendar tables: Calendar A and Calendar B.

yingyinr_0-1637660058004.jpeg

2. On page 1, create a date slicer with 'Calendar A'[Start of Month] as field. Copy the date slicer to page 2 and sync these two slicers as below. Hide the slicer on page 2.

yingyinr_1-1637660058058.jpeg

3. Create measures:

Selected Date = SELECTEDVALUE('Calendar A'[Start Of Month])
Measure = IF(MAX('Calendar B'[Start Of Month])<=[Selected Date],1,0)

4. On page 2, create a new date slicer with 'Calendar B'[Start of Month] as field. Add Measure into this slicer's visual filter and set value is 1. 

yingyinr_2-1637660058198.jpeg

5. The values may not be selected automatically, so I show "Select all" option in the slicer for user to select all the dates before the date selected on page 1. 


Best Regards

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@Anonymous , you can not create a new  table based on slicer value

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks! @amitchandak  Is there a workaround? or how do I make sure my end_date values are always greater than start_date values. I can't have a single slicer for a date. I need to have two slicers as I have to pass these values to the M query as a parameter. 

Anonymous
Not applicable

Hi @Anonymous ,

Please review the solution in the following thread and check whether that is what you want.

Dependent date slicers

1. Create two calendar tables: Calendar A and Calendar B.

yingyinr_0-1637660058004.jpeg

2. On page 1, create a date slicer with 'Calendar A'[Start of Month] as field. Copy the date slicer to page 2 and sync these two slicers as below. Hide the slicer on page 2.

yingyinr_1-1637660058058.jpeg

3. Create measures:

Selected Date = SELECTEDVALUE('Calendar A'[Start Of Month])
Measure = IF(MAX('Calendar B'[Start Of Month])<=[Selected Date],1,0)

4. On page 2, create a new date slicer with 'Calendar B'[Start of Month] as field. Add Measure into this slicer's visual filter and set value is 1. 

yingyinr_2-1637660058198.jpeg

5. The values may not be selected automatically, so I show "Select all" option in the slicer for user to select all the dates before the date selected on page 1. 


Best Regards

Anonymous
Not applicable

Thank you so much @Anonymous . The above approach works. But got below error when I tried to bind a parameter to start date and end date

monk_0-1637797935648.png

 

 

Solution to my question.

 

 

start_date_table = 
ADDCOLUMNS(
    CALENDAR(DATE(2021,8,1), DATE(2021,8,30)),
    "Start Date", FORMAT([Date], "YYYY-MM-DD")
)
end_date_table = 
ADDCOLUMNS(
    CALENDAR(DATE(2021,8,1), DATE(2021,8,30)),
    "End Date", FORMAT([Date], "YYYY-MM-DD")
)
Measure = IF(MAX(end_date_table[End Date]) >= [selected_start_date], 1, 0)
selected_start_date = SELECTEDVALUE(start_date_table[Start Date])

 

 

On page1, create a slicer with Start Date

Copy paste the slicer to page two

You get a pop up asking for sync - click sync

 

then on page two create slicer with End Date

drag on drop measure field into the End Date slicer and set measure is 1. Apply filter.

 

Hide the page 1

Anonymous
Not applicable

Hi @Anonymous ,

Thanks for sharing your solution here, it will help the others in the community find the solution easily if they face the same problem with you. Much appreciated!

Best Regards

Anonymous
Not applicable

@Anonymous  

I'm getting the below error when I tried to bind a parameter to start date and end date. Can you please help?

monk_0-1637869075977.png

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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