Highlight alternating sections of rows on a table (to differentiate based on a single column)

I have a table with a lot of data to show the page history of different users (sorted chronologically by User Pseudo ID). Is there a way to highlight every other section of rows associated with each User Pseudo ID? So the user can easily see each user's page history?

So in the screenshot below... the first row would be white, second would be grey, rows 3 & 4 would be white (because it's the same user psuedo id), row 5 would be grey... further down the bottom 9 rows would be the same color (either white or grey), etc.


Answers

  • Hi @NathanDorsch ,

    Not the best solution, but I hope this helps: https://www.loom.com/share/cd0cfd29478d441d923623714dfad678

    John Le

    You're only one dashboard away. 

    More video solutions at: https://www.dashboarddudes.com/pantry

    John Le

    You're only one dashboard away.

    Click here for more video solutions: https://www.dashboarddudes.com/pantry

  • You can utilize the DENSE_RANK window function and a MOD function to calculate alternating lines and then conditionally set your row coloring. MOD will return either 0 or 1 depending if it's even or odd to allow you to identify alternating rows.

    MOD(DENSE_RANK() OVER (ORDER BY MAX(`User Pseudo ID`)), 2)
    

    Sort your table based on the Pseudo ID as well.



    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Thanks Grant. Yeah, I ended up going that route... it's certainly not ideal though... :-(

    First, I have to have an extra column in there... and then when I filter by values in the other columns, it throws off the color alternating...

  • Lusi
    Lusi Member
    edited January 2023

    Hi, this helped me ALOT too, thank you Grant! I have a very similar issue. However, when I use the formula given: MOD(DENSE_RANK() OVER (ORDER BY MAX(`User Pseudo ID`)), 2) my rows reduce to singular entries instead of showing each row entry to do with the Rank. So ie Apple, Apple, Apple, Carrot, Carrot, turns into just Apple, Carrot... is there any way to keep both? the ranking and all the row entries? @grahamwalkeradv

  • sorry my last comment was actually for @GrantSmith