cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
_micom_
Level: Powered On

Max date

Hello!

Sorry for my English.

 

There are SharePoint lists with devices and repair dates.

Devices:

|     ID     |     DeviceTitle     |

------------------------------
|     1       |         dev1          |
|     2       |         dev2          |
------------------------------

Repair
|      ID     |      DeviceID     |      DateOfRepair     |
----------------------------------------------------
|      1      |        1                | DateTimeValue1     |
|      2      |        1                | DateTimeValue1     |

 

I need to get a collection where the last repair date is selected for each device.

 

I take two steps:

ClearCollect( DeviceReps; GroupBy( Repair; "DeviceId"; "Attestations" ));;
ClearCollect( LastRepDate; AddColumns( DeviceReps ; "MaxDate"; Max( Repair; DateOfRepair ) ) )

 

I get a collection DeviceReps:

 

|     DeviceID     |      MaxDate       |
-------------------------------------
|       1               | 1528664400000 |
|       1               | 1550700000000 |

How to get DateTime from 1528664400000? Or another way?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Max date

@_micom_ 

Max is going to return a number.  Converting that back to a date is a challenge.

 

Here's another option to consider:

ClearCollect( LastRepDate; 
AddColumns( DeviceReps ;
"MaxDate";
First(Sort( Repair; DateOfRepair; Descending)).DateOfRepair
)
)

This will sort the dates most recent being first and then take that first value of the DateOfRepair for your Column value.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Max date

@_micom_ 

Max is going to return a number.  Converting that back to a date is a challenge.

 

Here's another option to consider:

ClearCollect( LastRepDate; 
AddColumns( DeviceReps ;
"MaxDate";
First(Sort( Repair; DateOfRepair; Descending)).DateOfRepair
)
)

This will sort the dates most recent being first and then take that first value of the DateOfRepair for your Column value.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

_micom_
Level: Powered On

Re: Max date

 
 
 
 
 
 
 
 
 
 
 
 
 
 
Thank you very much. It works great for me.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,798)