Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

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!

 

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

2 Replies