Check a value against a list with IN
Replace a chain of OR tests with IN { … } to flag summer months, and leave the other months blank.
You will learn to
- Test a value against a list with IN { }
- Read the current row’s value with SELECTEDVALUE
- Return blank for “no” by leaving out IF’s third argument
How it works
“Is the month June, July or August?” could be written as three tests joined with `||`. The `IN` operator says it in one go:
`value IN { "a", "b", "c" }`
It is true when the value matches any item in the curly braces. Text items go in quotes; numbers do not, as in `IN { 6, 7, 8 }`. Make the items the same type as the value you test.
A measure cannot read a column directly, so ask for the row’s value with `SELECTEDVALUE(column)`. And if you only want to mark the matches, leave out IF’s third argument: the “no” rows return blank and stay empty in the visual.
Practice it hands-on with a real data model and a live report that updates as you type.
Sun Belt = IF(SELECTEDVALUE(Customer[Region]) IN { "South", "West" }, "Sun Belt")