Forum Discussion

matthewkaess's avatar
matthewkaess
Helper I
5 years ago
Solved

Grouping consecutive dates into a single row

I’m working on an object hire report that needs to group objects with consecutive borrowed on dates into a single row in a table visual. The available columns are; Object No Borrowed Date Returne...
  • AlB's avatar
    5 years ago

    matthewkaess 

    See it all at work in the attached file.

    I'm getting a bit lost. The example that you show (2504-Z004) has only one row in the data you've shared, with dates  18/01/2021 - 18/01/2021 , so the result you show is the correct one 

    Most of the Object No in your data have only one row. I had a look at the one with the larger number or rows (you can see them in the query Object Billing Export (TESTS) that I created to help in the debugging and they seem to work fine.

    I  uncommented the S2_ and S3_  ( to use the latest versions I'd suggested, you had the previous version active) and included sorting by Returned Date on this step, to get the dates completely sorted out before the crucial step: 

     

     

     

    Sorted by Object No = Table.Sort(#"Reordered Columns",{{"Object No", Order.Ascending}, {"Borrowed Date", Order.Ascending}, {"Returned Date", Order.Ascending}})

     

     

     

    plus it looks like the error you got  (Error - Unable to convert type null to type logical) was caused by cases like 

    3433-Z062 that had a null not as the very latest date in Borrowed Date. So I temporarily replaced those nulls with a date far in the future (31/12/9999) so that the row gets placed at the end when sorting ascending (the null woud be placed at the beginning since it is treated as as 0). Then at the end convert that 31/12/9999 back to null

     

    Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers