The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
https://www.dropbox.com/s/9es5uzaxjtrjm9l/SampleDATA.pbix?dl=0
Hello,
I'm looking for the closest date in (Table1) to the value (in Table2) based on the ID.
[the date should be greater than and not equal to]
I'm using the dax below, but the results are finding the closest value and ignoring the ID.
please help,
Expected Results:
Solved! Go to Solution.
Hi @darianle ,
Please try:
Column =
VAR _a =
MINX (
FILTER (
'Table1',
[ID] = EARLIER ( Table2[ID] )
&& DATEDIFF ( [MessageDate], [MessageDate2], MINUTE ) > 0
),
DATEDIFF ( [MessageDate], [MessageDate2], MINUTE )
)
RETURN
MINX (
FILTER (
'Table1',
[ID] = EARLIER ( Table2[ID] )
&& DATEDIFF ( [MessageDate], [MessageDate2], MINUTE ) = _a
),
[MessageDate2]
)
Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
works perfectly. thanks
Hi @darianle ,
Please try:
Column =
VAR _a =
MINX (
FILTER (
'Table1',
[ID] = EARLIER ( Table2[ID] )
&& DATEDIFF ( [MessageDate], [MessageDate2], MINUTE ) > 0
),
DATEDIFF ( [MessageDate], [MessageDate2], MINUTE )
)
RETURN
MINX (
FILTER (
'Table1',
[ID] = EARLIER ( Table2[ID] )
&& DATEDIFF ( [MessageDate], [MessageDate2], MINUTE ) = _a
),
[MessageDate2]
)
Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.