Habit Tracker Totals

Currently I am using a simple habit tracker I (basically created by @holroy) Input separated by comme as input for table

I am looking to add some totals per week and per activity. Sound simple enough, but I have been struggling with this for days.

Background:

In my weekly note, I have a simple line entry of some habits in the following format:
activityType, Activity, duration (min), distance (KM)

I basically use 3 activityTypes (exercise, learning, reading) but want could change up the ‘activity’ itself.

Examples.
exercise:: Walk, 20, 2.0
exercise:: Run, 60, 10.0
or
learning:: Harmonica, 45
learning:: Spanish, 60
or
reading:: Stoicism, 60
reading:: Summaries, 120

What I have sofar:

TABLE Type AS Activity, Duration AS Duration, DistanceOrQuantity AS Dist-Qty
FROM "2.0 CALENDAR/2.3 Periodic Notes"
WHERE exercise != null OR learning != null OR reading != null
FLATTEN flat(list(exercise) + list(learning) + list(reading)) as oneActivity
FLATTEN list(split(oneActivity, "\s*,\s*")) AS parts 
WHERE length(parts) >= 2
FLATTEN parts[0] as Type
FLATTEN parts[1] as Duration 
FLATTEN parts[2] as DistanceOrQuantity
SORT file.name DESC

Which gives me:

As you can see, I wasn’t even able to include the activityType in this dataview table.

What I’m trying to do

What I am aiming for is something as in the following Excel example:

I have worked on this for many days and looked at several other forum entries and the dataview help documentation. Still, I am not able to figure this out. Hopefully, some of you can.

Thank you,
RWvr