In the task 4 we create this measure:
1 %SalesAmountUnitedStates = DIVIDE([SalesAmountUnitedStates];
2 CALCULATE(SUM(fact_InternetSales[SalesAmount]); ALL(dim_SalesTerritory[SalesTerritoryCountry])))*100
I will like to know, if we already create 2 additional measures, why we didn’t simplify as this:
This is because TotalSalesAmount works with the current filter context. We won’t be able to get the correct result because of the way DAX works. If we divide SalesAmountUnitedStates by TotalSalesAmount, the formula engine would divide each row for SalesAmountUnitedStates vs Every Row of Sales Amount instead of the SUM of SalesAmount as a whole. This is why we are using the ALL function, it ignores the row context and provides a steady value for each row.