Can you try the following script:
=table(%($A2$); %($A2$); C$1; 2) - C$1
In %($A2$), the first dollar sign is to fix col(A) when extending to the right cells. The second dollar sign plus the percentage sign is substitution notation which substitute A2 by its content 1!C before execution.
https://www.originlab.com/doc/en/LabTalk/guide/Substitution-Notation#.25.28_.29_Substitution
In C$1, the dollar sign is to fix row 1 when extending the cells downwards.
James