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

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.

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
v-binbinyu-msft
Community Support
Community Support

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
Super User
Super User

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.