Filtering a related table
You can also pass to the FILTER
function the RELATED
function as the condition to limit the rows. In this recipe, you will filter your results to look at the Crash_Severity table and only use rows that are labeled as fatal.
How to do it...
On the CRASH_DATA_T table in the Grid view, select an empty cell under the CASENUMBER measure.
Enter the calculation in the formula bar:
Fatal_Crashes:=SUMX( FILTER(CRASH_DATA_T, RELATED(Crash_Severity[Severity_Descr])="fatal"), CRASH_DATA_T[INJURIES])
Once you have done this, hit Enter.
In this recipe, there are 2821 total fatalities that meet the condition.
How it works...
In this recipe, you are using the SUMX
and the FILTER
functions to calculate the total number of fatalities by summing the total INJURIES related to the Crash_Severity table. The SUMX
function applies the sum calculation to the INJURIES column, only on the records from the CRASH_DATA_T table that are...