Using aggregate function on data masked column returns zeroes
Since dynamic data masking is performed right before returning the query result to the user, applying functions such as AVG will not have the masked data as a resultset.
You can see this in the execution plan, the masking function appears right before the select (in other words, returning the data to the user):

While the actual aggreggate happens in the compute scalar right behind the masking function:

With [EXPR1008] and [EXPR1009] being a count and a sum:
&lt;ColumnReference Column=&quot;Expr1008&quot; /&gt;
&lt;ScalarOperator ScalarString=&quot;Count(*)&quot;&gt;
&lt;Aggregate AggType=&quot;countstar&quot; Distinct=&quot;false&quot; /&gt;
&lt;ColumnReference Column=&quot;Expr1009&quot; /&gt;
&lt;ScalarOperator ScalarString=&quot;SUM([Test].[dbo].[Salaries].[AmountUSD])&quot;&gt;

And, with the datamask function being applied after the aggregate functions, it is set to 0 as a result of the DataMask([Expr1002],0x05000000,(1),(0),(0),(0)) function.
This does not mean that all DataMask function executions on aggreggates and the corresponding datatypes will return 0, only that in this case it does.