Forum Discussion
PowerBI - Choosing a relative field between 2 dates
Hi tchooper7 ,
Please try using DAX to create the new column.
Name =
CALCULATE (
MAX ( 'Table 2'[Name] ),
FILTER (
'Table 2',
'Table 2'[Date] >= EARLIER ( 'Table 1'[Start Date] )
&& OR (
'Table 2'[Date] <= EARLIER ( 'Table 1'[End Date] ),
'Table 1'[End Date] = BLANK ()
)
)
)
Or create custom column in Power Query.
= let
s = [Start Date], e = [End Date]
in
Table.SelectRows(#"Table 2", each [Date] >= s and ([Date] <= e or e = null)){0}[Name]
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I don't think I explained it correctly - apologies.
In Table 1 has a start and end date and a field I want to appear in Table 2 according to the date in Table 2
Example
Table 1 Start Date End Date Name
Line 1 : 1/7/2020 30/6/2021 Teresa
Line 2 : 1/7/2019 Joe
I want to appear in Table 2
Date of Transaction New Column
Line 1 15/7/2020 Teresa
Line 2 10/7/2019 Joe
Any thoughts please
Teresa