Search code examples
google-sheetscharts

Blood Sugar Chart for Two Diabetic Cats in Google Sheets


I'm having a terrible time trying to create what I thought would be a simple line chart to track blood sugar for my two diabetic cats. I want two lines, one for each cat, tracked by date/time. I have four columns: Date, Time, Cat, and Blood Sugar. I can't get the chart to have a separate line for each cat. Cat is the name of whichever cat I was taking the reading for at the specified Date and Time, Blood Sugar is the numeric sugar level. Any help appreciated! The data looks like:

Date      | Time     | Cat    | Blood Sugar
6/4/2024  | 9:00 AM  | Aurora | 125
6/4/2024  | 11:00 AM | Aurora | 119
6/11/2024 | 1:00 PM  | Aramis | 157
6/11/2024 | 3:00 PM  | Aramis | 125
6/11/2024 | 11:00 AM | Aurora | 122
...

Solution

  • You could restructure the input data using a formula & then apply the chart over it as such:

    =arrayformula(query(hstack(A:A+B:B,C:D),"select Col1,max(Col3) Where Col2<>'' group by Col1 pivot Col2 label Col1 'DateTime' format Col1 'e-m-d h:mmAM/PM'"))
    

    enter image description here