You are taking interesting approach, but I recommend normal approach.
From edit data source, pivot data for Measure fields.
create couple of calc fields.
Demo_refline_SM_10.0.twbx 37.1 KB
Thank you so much for your reply and instructions! Super helpful! One little question: sometime I can't find "pivot" option in data source, have you ran into this situation and how to solve this?