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

Regards
Zubair

Please try my custom visuals

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 )

Regards
Zubair

Please try my custom visuals

@Anonymous

 

Please see attached file as well

 

corey.png


Regards
Zubair

Please try my custom visuals

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.