May 02 2020 12:24 PM
I am working on a data set output from a blood sugar test meter (Bayer Contour Next USB)
1020 rows, 19 columns. Imported as CSV.
I want to sort the data by the date column but from row 400 onward it will not sort by date order. I have tried altering the date format of the column, but only rows 1 to 399 will do change format, the rest stay as they were and the sort function does not recognise the rows as dates and will not sort them.
I have tried saving as .xlsx. Same problems.
Any ideas anyone?
May 02 2020 12:47 PM
That's since some "dates" are kept as text, some are converted wrongly.
Importing csv file do not rely on automatic conversion. If that's legacy wizard, on third step apply Date to this column with MDY format.
May 03 2020 04:07 AM
@Stewart_H some date in date column is import as text for sorting all the date it is essential that all are in date format i used text to column in data tab to convert all your date in date format i have attached a solution file check it,
May 03 2020 04:32 AM
I'm not sure that is correct result. Let take these two records in initial file
Most probably in #54 in source csv file it was 11/08/2019. Since both 11 and 08 are less than 12, Excel was interpreted $54 as date in local format and converted to Aug 11. Text to Columns on result keeps converted date as it is, thus we have
Most probably in #54 it shall be Nov 08, or 2019-11-08 in ISO format. Same for some other records.
Thus I'd suggest to convert properly source csv file, not to transform intermediate files.
May 03 2020 06:58 AM
Yes, that is the issue. Some of the text will not reformat to date.
The CSV file is created by the software on the blood test meter which is not accesible by me. Can I control how excel converts it when I open the CSV file?
@Khizar_Hayyat has managed to convert all cell to date format but day and month have been mixed up.
@Khizar_Hayyat How did you convert all to date format? Simple explaination for excel novice please.
May 03 2020 07:14 AM
It's better not to click on csv file to open it, but import csv into the blank Excel file. How to do - it depends on which version of Excel you are.
Assuming one of the latest for Windows Desktop. Here is also two options. You may enable legacy From text connector in options
and use it as
for older Excel that's the only option by default.
After you select the file it'll be 3-steps wizard, practically same as for Data->Text to Columns which @Khizar_Hayat used. Here select separation by delimiter, your delimiter, and on 3rd step of the wizard check Date for the column with dates and select MDY format.
Another way is default for the latest Excel option uses Power Query
which is much more powerful and most probably will give you correct result without additional manipulations, but it requires to invest bit more time to start working with it.
May 03 2020 01:09 PM