Forum Discussion
Calculate date between 2 rows
- 4 years ago
Okay, so if you revert to your second screenshot (your initial response to me), you could select one of the pivoted columns (start or end) and then select 'Fill' from the Transform tab within the ribbon (Up or Down will depend on if you've used start or end). Then you can just deselect the NULLs from the other column and I think this should get you there.
Hi BITomS ,
Thank you for your answer
The problem is that I always find myself having to calculate a duration according to 2 dates that are on two lines
Regards
Arnaud_37 providing all other column values, other than Message and DateHeure, are the same for the start and end rows, this should not happen (i.e. if all other columns have consistent values that relate to the same 'action', pivoting the data will consolidate everything into one row).
Your latest screenshot suggests there is (at least) one column where the row values do not match for the same action, so you need to ensure your table only contains relevant columns with consistent values per action - looking at your screenshot from your original post, I am wondering if you have removed the 'Heure' column before attempting to pivot the data? As this is different across both start and end rows, it is probably what is causing your data to not pivot correctly. Try removing this column first and see if this makes a difference.
- Arnaud_374 years agoNew Member
I simplified my columns and I get:
but when i pivot the "message" column with the "DateHeure" column then i have an error message: "There are too many elements in the enumeration to complete the operation"
- BITomS4 years agoSolution Supplier
Ha, I think you have removed too many columns now - if you only have Message and DateHeure, there is no other column for Power Query to reference to identify that a start and end time relates to the same action. Power Query will be assuming all those start and end times relate to the same single action, so cannot logically apply all those times to 2 columns within the same row, creating the error.
Without having access to your model, I would assume there must be an ID column or similar in order to distinguish one action from another? If this is not available, it is this lack of an ID column that will be causing you an issue for calculating between 2 times - otherwise how else will Power Query know which start time relates to which end time?
- Arnaud_374 years agoNew Member
I understand,
But my data come from log file.
I have one line where it is written "Process started" (with date, time and other things).
the line after write "Process ended".
the line after write "Process started"
....