google sheets – Data Studio formula for one-to-many count

I have a large table of transaction data that I am trying to analyze. The table is formatted with a transaction having multiple rows depending on the number of items purchased (one row for each item).

I am using Google Data Studio to visualize my data, but can’t figure out how to make a count of how many transactions contain a combination of two products. I can count how many of product A are purchased and how many of product B, but not how many transactions purchase both A&B.

I’ve tried multiple if statements, but keep facing boolean vs text issues. I’ve also tried case functions but can’t seem to get one that works. How can I build a formula for a custom field that lets me count this?