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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Timerange filter from selected row

Hi everyone,

I have ran into problem and hope to get some nice tips here from the community. 🙂

I have two tables.

Table 1 basically defines different timeranges by the columns 'Start' and 'End':

IDStartEnd
11/1/20211/5/2021
21/4/20211/7/2021
31/6/20211/10/2021
41/9/20211/12/2021

Table 2 contains different datapoints with a column 'Date':

IDDateValue
11/1/2021 0.5
21/2/2021 5.2
31/3/2021 3.1
41/4/2021 4.9
51/5/2021 8.5
61/6/2021 2.5
71/7/2021 6.8
81/8/2021 0.5
91/9/2021 7.2

 

My goal is to filter Table 2 on 'Date' by the timerange defined by 'Start' and 'End' when selecting a row of Table 1.

What I have learned during my research is, that

1) I need a calculated measure instead of a calculated column to get 'Start' and 'End' values of the selected row of Table 1
2) I need a calculated column in Table 2 to check for every column if 'Date' is between 'Start' and 'End'

3) A calculated column can not access the updated value of a calculated measuere, because the measure calculation is executed after the calculation of a column and the calculation of a column gets not updated over time.

 

And this leads to the situation, that I am not able to filter Table 2 regarding the selected 'Start' and 'End' of Table 1.

 

One idea I had, to resolve that, is to do an Outer Join in beforehand on Table2.Date is between Table1.Start and Table.End. But this would leave we me with performance issues since my real data table contains almost a million events and thousands of timeranges.

 

I am verry happy to get any suggestion, ideas or hint how to deal with that kind of problem. 🙂

best regards and thanks a lot in advance,
Marvin

1 ACCEPTED SOLUTION
AntonioM
Solution Sage
Solution Sage

You can do all of those steps with a measure, which you use to filter Table 2. 

 

If you use:

Table Filter Measure = 
var 
    _start = SELECTEDVALUE('Table'[Start])
var 
    _end = SELECTEDVALUE('Table'[End])
var
    _date = SELECTEDVALUE('Table (2)'[Date])
return
    IF( _date <= _end && _date >= _start, 1,0)

 

 Then that will give you 1s for any row within the date range, when you select a row from Table

 

AntonioM_0-1659518278181.png

You can then apply that as a filter to a visual

AntonioM_2-1659518431965.png

Or to filter another measure, such as

Filtered Measure = CALCULATE ( [Measure], FILTER( Table2, [Table Filter Measure] = 1 ) )

 

 

 

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi Antonio, you are amazing! Thanks a lot! 🙂

AntonioM
Solution Sage
Solution Sage

You can do all of those steps with a measure, which you use to filter Table 2. 

 

If you use:

Table Filter Measure = 
var 
    _start = SELECTEDVALUE('Table'[Start])
var 
    _end = SELECTEDVALUE('Table'[End])
var
    _date = SELECTEDVALUE('Table (2)'[Date])
return
    IF( _date <= _end && _date >= _start, 1,0)

 

 Then that will give you 1s for any row within the date range, when you select a row from Table

 

AntonioM_0-1659518278181.png

You can then apply that as a filter to a visual

AntonioM_2-1659518431965.png

Or to filter another measure, such as

Filtered Measure = CALCULATE ( [Measure], FILTER( Table2, [Table Filter Measure] = 1 ) )

 

 

 

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors