Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
105 | |
105 | |
88 | |
73 | |
66 |
User | Count |
---|---|
124 | |
113 | |
98 | |
80 | |
72 |