I have a table of university unit data. The units have historically been delivered in two different lengths (under the same unit code): sessions and terms. It looks something like this:
| UnitCode | Year | OfferedIn |
|---|---|---|
| UNIT001 | 2021 | Session1 |
| UNIT001 | 2021 | Session2 |
| UNIT002 | 2021 | Session1 |
| UNIT002 | 2021 | Term4 |
| UNIT003 | 2020 | Session1 |
| UNIT003 | 2020 | Session3 |
| UNIT003 | 2021 | Term2 |
I need to slice various graphs by units that were offered in both styles, regardless of which actual year, session, or term. So the extra column would be as on the right below:
| UnitCode | Year | OfferedIn | OfferedInBoth |
|---|---|---|---|
| UNIT001 | 2021 | Session1 | |
| UNIT001 | 2021 | Session2 | |
| UNIT002 | 2021 | Session1 | TRUE |
| UNIT002 | 2021 | Term4 | TRUE |
| UNIT003 | 2020 | Session1 | TRUE |
| UNIT003 | 2020 | Session3 | TRUE |
| UNIT003 | 2021 | Term2 | TRUE |
So I want to look at a value in the UnitCode column and see if it has both different kinds of values in the OfferedIn column (I can do 'contains' expressions for the types) in any row where the unit code is the same. How do I generate the OfferedInBoth column? (Or do I need to create a new table? I'd prefer to keep it as dynamic as possible, as the dataset will add new unit codes over time.)
