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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
kk1988
Frequent Visitor

Power BI Slicer for start and end date

Hi Team - I have start date and end date fields in my data set. I want to create a slicer so the user can select the date range between these dates like below. There are records where the end date is NULL as well so in that case how to solve this date range ? 

Could you please help, how this can be done ? 

kk1988_0-1711547698537.png


My dataset is simple with ID, NAME, Description, City, Employee city, Products, Price, START DATE , END DATE.


1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @kk1988 

Thanks for the solution @lbendlin provided, and I want to offer some more information for you to refer to.

If your end date is blank, you can consider to use the max end date for the current table, you can refer to the following solution.

Sample data 

vxinruzhumsft_0-1711595345417.png

1.Create a calendar table.

Calendar = CALENDAR(MIN('Table'[Start Date]),MAX('Table'[End Date]))

2.Create a relationship between the tables

vxinruzhumsft_1-1711595412708.png

 

3.Create a calculated column in data table

End Dates = IF([End Date]<>BLANK(),[End Date],MAX('Table'[End Date])) 

4.Creat a measure

MEASURE =
VAR a =
    CALCULATETABLE (
        CALENDAR ( MIN ( 'Table'[Start Date] ), MAX ( 'Table'[End Dates] ) ),
        CROSSFILTER ( 'Calendar'[Date], 'Table'[Start Date], NONE )
    )
VAR b =
    VALUES ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        IF ( COUNTROWS ( INTERSECT ( a, b ) ) > 0, SUM ( 'Table'[Price] ) ),
        CROSSFILTER ( 'Calendar'[Date], 'Table'[Start Date], NONE )
    )

5.Put the date of the calendar table to the slicer.

Output

vxinruzhumsft_2-1711595535590.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

View solution in original post

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi @kk1988 

Thanks for the solution @lbendlin provided, and I want to offer some more information for you to refer to.

If your end date is blank, you can consider to use the max end date for the current table, you can refer to the following solution.

Sample data 

vxinruzhumsft_0-1711595345417.png

1.Create a calendar table.

Calendar = CALENDAR(MIN('Table'[Start Date]),MAX('Table'[End Date]))

2.Create a relationship between the tables

vxinruzhumsft_1-1711595412708.png

 

3.Create a calculated column in data table

End Dates = IF([End Date]<>BLANK(),[End Date],MAX('Table'[End Date])) 

4.Creat a measure

MEASURE =
VAR a =
    CALCULATETABLE (
        CALENDAR ( MIN ( 'Table'[Start Date] ), MAX ( 'Table'[End Dates] ) ),
        CROSSFILTER ( 'Calendar'[Date], 'Table'[Start Date], NONE )
    )
VAR b =
    VALUES ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        IF ( COUNTROWS ( INTERSECT ( a, b ) ) > 0, SUM ( 'Table'[Price] ) ),
        CROSSFILTER ( 'Calendar'[Date], 'Table'[Start Date], NONE )
    )

5.Put the date of the calendar table to the slicer.

Output

vxinruzhumsft_2-1711595535590.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

lbendlin
Super User
Super User

A range slicer can only be fed by a single column.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Solution Authors
Top Kudoed Authors