Using the AND function
The AND
function is similar to the IF
function. When you use this function, it is checking two arguments at the same time to determine if the condition is true
or false
. When both arguments are true, then the function returns true. In this recipe, you will add a function on a new column to determine if the record is a single or multiple vehicle fatality. The AND
function has a required syntax of AND(<logical1>, <logical2>)
.
How to do it...
Open the Chapter_9_DAX solution, select the CRASH_DATA_T table, and make sure you are in the data Grid view.
Scroll to the right until you find the Add Column. Then in the expression box, add the formula to determine the number of vehicles and number of fatalities involved and press Enter to create the calculation. You will then see a label added to each row:
=IF( And ( [FATALITIES]>=1, [VEHICLES]=1), "Single Vehicle Fatality", "Multiple Vehicle Fatality" )
On the Properties window, change the...