The Total value is not the sum of the rows above it, it is calculated on its own, so the result can be unexpected if you don’t understand this aspect. A Google search will find many explanations of how to understand this.
@Marta,
What if you wrapped the calculation in a SUMX( VALUES like the following: ( I find it easier and more productive to create these measures separately and then put them together)
Start with your based measure. Total Sales in this case: Total Sales = SUM( FactOnlineSales[SalesAmount] )
Then create the RankX measure: Rank = RANKX( ALL( DimCustomer), [Total Sales],,DESC,Dense )
Then the final measure to get the correct totals: Top 10 with Correct Total = SUMX(VALUES(DimCustomer[CompanyName]),IF( [Rank] <= 10, [Total Sales]))