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.
Ps Thank you for trying to help me
- v-kkf-msft4 years ago
Community Support
Hi tchooper7 ,
Does this result match your desired output?
= let CurDate = [Date of Transaction] in Table.SelectRows( Table.Sort(#"Table 1",{{"Start Date", Order.Descending}}), each [#"Start Date"] <= CurDate and ([#"End Date"] >= CurDate or [#"End Date"] = 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.