Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
paw1
Helper I
Helper I

latest Timestamp date

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

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @paw1 

try like:

column = MAX([Date1], [Date2])

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

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 )
    )

 

vbinbinyumsft_0-1675996532987.png

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.

serpiva64
Solution Sage
Solution Sage

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])

serpiva64_0-1675941555414.png

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!

FreemanZ
Super User
Super User

hi @paw1 

try like:

column = MAX([Date1], [Date2])

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.