# Filtering and Sorting a Table that has more than 1 row per user

Imagine if... you had 6 users. They all drove cars. The table shows which cars they drive and how many miles they have driven each car. It also shows a flag which is just a way to tag a user that is important.

The License column is how many days before their driver's license expires (has nothing to do with the cars, only the user. It's the user's license).

The Last Drove is how many days ago a user drove any of their cars.

OK, so... What if you want to filter by 2 cars types (Ferrari & Mercedes):

Now the problem - What if you wanted to sort the Miles Column from low to high:

Problems:

1. The Name column will have to repeat user names so that the Miles column can list numbers from low to high (users are no longer grouped)
2. The Flag column will have to duplicate the flag next to each duplicated user Name
3. The License and Last Drove columns will also have to duplicate its numbers for each repetition of a user Name (same as flag problem)
4. The license belongs to the user not the car, so it shouldn't be duplicated per car, that's very redundant data. It should be attached to the user but it also needs to be sortable.

Question: Has anyone come across this before and solved it maybe by showing the table a little differently or adding a mechanic that stops having to repeat data (name, flag, license, last drove)?

Something I tried but doesn't work is:

• I added a 'totals' row above each user that has more than 1 car. That helps sort on just the user's total (keeping their group together at all times) but doesn't work logically because I don't want to compare a user's single car MILES with another user's group of car MILES. (If user1 has 100 miles on one car and 2 miles on another, I don't want the user's group of 2 cars to be near the bottom of the Miles sorted column as 102 miles, I want to know that one of the user's cars is only 2 miles and should be near the top of the column when sorted.)

Thank you

Each row in a table should tell an easy-to-understand story.

When you read a table row from left-to-right (in LTR languages), you should be able to understand what the information is trying to say without thinking about what belongs to what.

In your example, you have some information that belongs to the driver, and some that belongs to the car. I think you need to decide who is the "hero of the story" - the driver, or the driver's car?

If the driver's information is more important than the car's, and you need to tell its story at a glance, you can design something like this:

However, you said that it's important to be able to filter and sort on the car info, because that's what the user might have specific questions about. That leads me to believe that the car is the "hero" and the user's details can be subordinated. In that case, you could put the user details in a tooltip. You would have to put the user's name on each line, but that's good for consistency, and makes it easy to just "read the row" without having to skip around and find out who the driver is.

By the way, if you're not filtering or sorting on the flag, it's an indicator, and can go next to the user's name in both cases.

I think the problems you raise in your questions are not really problems of ordering or classifying data within a table, but that you are seeing the issue only in two dimensions as a double-entry table when in reality interactivity allows you to use more than one x/y reading.

The duplicates problem in a table is not something new, there are font management applications that allow performing a search for duplicates, offering the result in a visible way. Or spreadsheet applications with duplicate rows...

First of all, I would highlight the repeated data with color, text indenting, semi-transparency...

Secondly, I would use the interactivity as a top layer, allowing the user to decide if they want to see the duplicate information:

• Alerting there are duplicate data. With an icon/button next to the most relevant item I think is enough
• Showing duplicated data by clicking on the icon
• Showing the matched items when hovering one of them

• Thank you for the detailed answer and taking time to look at this. - I think the highlighting of duplicate user data is a good idea. I had thought of greying out duplicate rows a little or adding 1/3, 2/3, 3/3 after each user name but your color and interactive idea is better. Commented May 27, 2022 at 20:54
• If the table was really long (1000 rows) then it wouldn't be obvious which rows were duplicate ones as you would need to look at 1000 rows to find all the highlighted ones, and that wouldn't work with pagination. But I will think more about what you proposed. Thanks again. Commented May 27, 2022 at 20:58