Matt Allington explains when to use SUM() or SUMX() in DAX:

Example: Total Sales SUMX = SUMX(Sales,Sales[Qty] * Sales[Price Per Unit])

SUMX() will iterate through a table specified in the first parameter, one row at a time, and complete a calculation specified in the second parameter, eg Quantity x Price Per Unit as shown in the example above for the current filter context. Once it has done this for every row in the specified table in current filter context, it then adds up the total of all of the row by row calculations to get the total. It is this total that is returned as the result.

This is a really good explanation of the topic.