Wow! Thank you so much for taking the time to put this together. I do have more questions. 
The first thing I noted when I went into your example is that the ābinary 1ā and ābinary 0ā values in Table 1 are in little grey boxes. Iāve accidentally clicked Reference List as a data type, so Iāve seen this but never used it. Can you explain why you did it that way?
Is the code string youāve shared python? (Iām assuming it is) ā Iāve got a very small amount of python knowledge, but it looks very familiar to R, which I am quite comfortable in. This looks like a next-level VLOOKUP in excel, which is an old friend Iāve been trying to ditch for years (we broke up because I love left_join so so much).
I just want to reiterate back to you what I think the code is doing to see if Iām on the right track. len
is looking for the length of whatās returned. lookupRecords
requires a column in the new table where this code will go called $Name
and the code string looks for records in the table Task_Type_1
where Name
equal to the value in the particular row of the new table and counts the values equal to the text string "binary 1"
or "binary 0"
and reports out the length (len
) of the records that match the query of the particular name and the particular outcome.
This is making sense
ā I hope Iām on the right track. I got it to calculate within my own workspace, so I feel like I might be onto something! (Note: I did not have to turn my Outcomes
into a Reference List type, so I am even more curious why your little grey boxes are present).
Having successfully cleared this hurdle (thanks in large part to you!), the next thing Iād like to do is get a sum of the total number of events each person participated in. Even after I change the count columns in Table 2 to data type numeric, I canāt use sum($Binary_0_Count, $Binary_1_Count)
in a new column to compute that (I get #TypeError, āfloatā object is not iterable). (I also tried =$X+$Y
but that had the same issue). Further, Iād like to know their āsuccess recordā so in addition to seeing the total number of events, Iād like to take their successes or $Binary_1_Count
and divide it by the total number of events.
Now, going back to gristHelper_Display
sometimes if I donāt use the gristHelper
I get a data error, and sometimes I expect to be able to reference something but it doesnāt appear to be there. I think this is because my references are sometimes too far detached from the data Iām pointing to.
For example, within the table Task_Type_1
thereās a column that links the name and outcome to a specific event (with an event ID) and then thereās another table (Events) linking the event ID to a year.
I can use =$event_ID.Year
to get the year. Yet another table (Years) that gives metadata about specific years. One piece of info is a Boolean/Toggle variable. Letās say I want to pull in that Boolean variable. Since Year is already the type of data that has an =
sign at the beginning (what I think of as a reference, but Iām not sure thatās the right terminology) , I canāt query it for the Boolean variable. That is when I type =$Year.
there are no options listed (even though I know there are many fields connected to the Year
code via the Year
table).
Iād like to be able to say =$Year.Boolean
and then (I think) I would be able to add an argument to the len
column that says Boolean = True
or something to that effect⦠but since the two variables, Boolean and event, have an intermediary piece of data connecting them (Year), that doesnāt seem possible (though after your amazing answer here, Iām almost certain it is!)
Alternatively, I could manually enter a list of years (ones where my Boolean variable is true) and that would also work, but Iām not sure how I might do that (in R, it would be using %in%
with c(X, Y, Z)
within the argument).
Thank you, again, for your help! Iām having wayyy too much fun learning here. Grist as a connection between SQL/relational databases and spreadsheets has unlocked something remarkable in my brain. Grist is so, so powerful and itās been such a pleasure to fumble around in it.