Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi Team,
Could you please help me to derive Expected output column from Date1, Date2 columns
Logic:
If Date1 is null then Date2 need to consider,
If Date2 is null then Date1 need to consider,
if Date 1 and Date 2 both exists then need to consider latest Date based on dd/mm/yyyy hh:mm:ss
Main ID | Sub ID | Date1 | Date2 | Expected output |
68 | 52 | 9/11/2022 12:06:00 |
| 9/11/2022 12:06:00 |
499 | 61 | 14/11/2022 08:29:00 |
| 14/11/2022 08:29:00 |
499 | 62 | 14/11/2022 08:29:00 |
| 14/11/2022 08:29:00 |
77 | 40 |
| 09/11/2022 6:29:00 | 09/11/2022 6:29:00 |
77 | 41 |
| 09/11/2022 6:30:00 | 09/11/2022 6:30:00 |
499 | 60 | 14/11/2022 08:29:00 | 14/11/2022 13:05:00 | 14/11/2022 13:05:00 |
468 | 78 | 8/12/2022 11:53:24 | 8/12/2022 12:02:26 | 8/12/2022 12:02:26 |
766 | 47 | 8/12/2022 12:42:27 | 8/12/2022 12:42:55 | 8/12/2022 12:42:55 |
766 | 80 | 8/12/2022 12:48:17 | 8/12/2022 12:46:25 | 8/12/2022 12:48:17 |
Solved! Go to Solution.
Hi @paw1 ,
@serpiva64 solution is achieved in Power Query, There is an another way to create a conditional column with DAX.
Please try to create a new column with below dax formula:
Column =
VAR cur_date1 = [Date1]
VAR cur_date2 = [Date2]
RETURN
SWITCH (
TRUE (),
ISBLANK ( cur_date1 ), cur_date2,
ISBLANK ( cur_date2 ), cur_date1,
NOT ( ISBLANK ( cur_date1 ) ) && NOT ( ISBLANK ( cur_date2 ) ), IF ( cur_date1 > cur_date2, cur_date1, cur_date2 )
)
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
you need to add a conditional column like this
= Table.AddColumn(#"Changed Type", "Custom", each if [Date2] = null then [Date1] else if [Date1] = null then [Date2] else if [Date1]>[Date2] then [Date1] else [Date2])
If this post is useful to help you to solve your issue, consider giving the post a thumbs up and accepting it as a solution!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 40 | |
| 39 | |
| 34 | |
| 29 | |
| 24 |
| User | Count |
|---|---|
| 122 | |
| 111 | |
| 83 | |
| 69 | |
| 68 |