Error on percentageoftotal formula

Hi team, I wanted to calculate % of # of opportunities at each stage over the total, for example, ‘Prospect’ = 27.5% (35/127). I know that I need to first create total number of opps across all stages, then calculate the % on each stages. However, when I distinct count opps ids on all stages, I got this error. Could someone pls help with this, thanks in advance!

–Error message

–Ultimate Goal

Hi @ChenjingLyu
The second argument must be an array. please enclose it in .

However, In pivot table there are built in table calculation that helps you achieve percent of Total.