Filtering based on a value
You can also filter your model to return the data you need for your analysis using the FILTER
function. Using this function, you can limit the results on a table by applying an expression that is evaluated on each row of the table. For example, if you wanted to know the total number of crashes that had more than two major injuries, the FILTER
function has a required syntax of FILTER(<table>,<filter>)
.
Getting ready
In this recipe, you will create a filter to sum the total fatalities on crashes that have more than two major injuries.
How to do it...
On the CRASH_DATA_T table in the Grid view, select an empty cell under the Count_of_Crashes measure.
Enter the calculation in the formula bar:
Total_Fatalities_GT2_MajorInjuries := SUMX( FILTER(CRASH_DATA_T, CRASH_DATA_T[MAJINJURY]>2), CRASH_DATA_T[FATALITIES] )
Hit Enter.
In this recipe, there are 88 total fatalities that meet the condition of
CRASH_DATA_T...