HASONEFILTER
Whether a column is filtered directly to exactly one value.
Group: Information. Compatible with DAX.
Syntax
HASONEFILTER ( <columnName> )
| Parameter | Type | Description |
|---|---|---|
columnName | Column | The column whose own filters are looked at. |
Returns
Boolean. TRUE when the filters set on the column itself leave exactly one of its values.
Remarks
- Only filters on this very column count: a slicer or a visual's grouping on it, a
CALCULATEfilter on it, or a filter over its whole table. A single value left over because some other column is filtered does not:HASONEVALUEis TRUE then, HASONEFILTER FALSE. - With no filter on the column it is FALSE, even when the column holds a single value.
- When several filters on the column meet (one of them with
KEEPFILTERS), it is the values they all keep that are counted. - It suits a measure that should react only to what the report reader picked for this column; to ask what the picked values are, use
FILTERS.
Examples
One product left, but not picked
Cider is the only product of its category: the category's row leaves one product, yet nothing filters the product column itself.
EVALUATE
SUMMARIZECOLUMNS (
ROLLUPADDISSUBTOTAL ( Products[Category], "Total" ),
"Products", COUNTROWS ( VALUES ( Products[Product] ) ),
"HASONEVALUE", HASONEVALUE ( Products[Product] ),
"HASONEFILTER", HASONEFILTER ( Products[Product] )
)
ORDER BY [Total], Products[Category]
| Products[Category] | Total | Products | HASONEVALUE | HASONEFILTER |
|---|---|---|---|---|
| Beer | FALSE | 3 | FALSE | FALSE |
| Cider | FALSE | 1 | TRUE | FALSE |
| (blank) | TRUE | 4 | FALSE | FALSE |
Filters of CALCULATE
EVALUATE
ROW (
"IPA", CALCULATE ( HASONEFILTER ( Products[Product] ), Products[Product] = "IPA" ),
"IPA or Pils",
CALCULATE (
HASONEFILTER ( Products[Product] ),
Products[Product] = "IPA" || Products[Product] = "Pils"
),
"Category Cider", CALCULATE ( HASONEFILTER ( Products[Product] ), Products[Category] = "Cider" ),
"No filter", HASONEFILTER ( Products[Product] )
)
| IPA | IPA or Pils | Category Cider | No filter |
|---|---|---|---|
| TRUE | FALSE | FALSE | FALSE |
Related functions
HASONEVALUE, ISFILTERED, FILTERS, SELECTEDVALUE, ISCROSSFILTERED.