Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I'm trying to create a column in which i want to compare two dates and if the two dates match, took the value from another column if the dates not exact match it gives the value of nearest date match.
need help
Regards,
Syed Muhammad Akber
Solved! Go to Solution.
Hi, @Akbera1
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create a calculated column or a measure as below.
Calculated column:
Result Column =
IF(
[Date1]=[Date2],
[Another Date],
var _diff1 = ABS(TODAY()-[Date1])
var _diff2 = ABS(TODAY()-[Date2])
return
IF(
MIN(_diff1,_diff2)=_diff1,
[Date1],
[Date2]
)
)
Measure:
Result Measure =
var _date1 = SELECTEDVALUE('Table'[Date1])
var _date2 = SELECTEDVALUE('Table'[Date2])
return
IF(
_date1=_date2,
SELECTEDVALUE('Table'[Another Date]),
var _diff1 = ABS(TODAY()-_date1)
var _diff2 = ABS(TODAY()-_date2)
return
IF(
MIN(_diff1,_diff2)=_diff1,
_date1,
_date2
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Akbera1
Could you please show us some sample data and expected result with One Drive for Business? Do mask sensitive data before uploading. Thanks.
Best Regards
Allan
Hi, @Akbera1
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create a calculated column or a measure as below.
Calculated column:
Result Column =
IF(
[Date1]=[Date2],
[Another Date],
var _diff1 = ABS(TODAY()-[Date1])
var _diff2 = ABS(TODAY()-[Date2])
return
IF(
MIN(_diff1,_diff2)=_diff1,
[Date1],
[Date2]
)
)
Measure:
Result Measure =
var _date1 = SELECTEDVALUE('Table'[Date1])
var _date2 = SELECTEDVALUE('Table'[Date2])
return
IF(
_date1=_date2,
SELECTEDVALUE('Table'[Another Date]),
var _diff1 = ABS(TODAY()-_date1)
var _diff2 = ABS(TODAY()-_date2)
return
IF(
MIN(_diff1,_diff2)=_diff1,
_date1,
_date2
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
64 | |
63 | |
52 | |
39 | |
24 |
User | Count |
---|---|
80 | |
57 | |
45 | |
44 | |
35 |