The purpose of the CALCULATE
function is to apply a measure or calculation expression to a filtered set of rows, usually by calling another function that returns a table object. We will use the FILTER
function to explicitly filter rows in the Internet Sales
table where related rows from the Sales Territory
table have a SalesTerritoryCountry
column value equal to United States
. Using these functions, we will define the filter context.
Follow the given steps to use the CALCULATE
function:
Return to the
Internet Sales
table in grid view and select a new cell in the Calculation Pane. Write a new calculated measure namedUS Sales
as follows:US Sales:=CALCULATE( [Sales Amount], 'Internet Sales', 'Sales Territory'[SalesTerritoryCountry] = "United States" )
Move on to another cell and write a similar measure named
Non-US Sales
. The only difference from the previous example is that the value is not equal toUnited States
. It should look similar to the following...