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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Calculated Column: Apply Value for Time Span from other Table

Hi there,

 

I would like the output of table 2 "Desired Output Column"

 

The output is the ID from Table1 when Date2 is >= Date1 and Date2 < Date1 (index+1) . See table2 for example.

 

Table1

Date1ID
1/1/2018Cat
2/1/2018Dog
3/2/2018Rabbit

 

Table2

Date2ValueDesired Output Column
1/1/20185Cat
1/2/20186Cat
1/3/20183Cat
1/4/20186Cat
1/5/20183Cat
2/1/20184Dog
2/2/20186Dog
2/3/20183Dog
2/4/20181Dog
2/5/20181Dog
3/3/20183Rabbit
3/4/20182Rabbit
3/5/20183Rabbit
3/6/20184Rabbit
3/7/20185Rabbit

 

Any thoughts? thanks!

 

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

Try this calculated column

 

Column =
VAR FirstDate_For_ID =
    CALCULATE ( MAX ( Table1[Date1] ), FILTER ( Table1, [Date2] >= [Date1] ) )
RETURN
    CALCULATE ( MIN ( Table1[ID] ), Table1[Date1] = FirstDate_For_ID )

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

Try this calculated column

 

Column =
VAR FirstDate_For_ID =
    CALCULATE ( MAX ( Table1[Date1] ), FILTER ( Table1, [Date2] >= [Date1] ) )
RETURN
    CALCULATE ( MIN ( Table1[ID] ), Table1[Date1] = FirstDate_For_ID )

@Anonymous

 

Please see attached file as well

 

corey.png

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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