OpenBI Docs Buy

CROSSFILTER

As a filter of CALCULATE, sets which way a relationship filters for the calculation: one way, both ways, or not at all.

Group: Relationships. Compatible with DAX.

Syntax

CROSSFILTER ( <columnName1>, <columnName2>, <direction> )
ParameterTypeDescription
columnName1ColumnOne column of the relationship, usually the one on its many side.
columnName2ColumnThe relationship's other column.
directionKeywordBOTH, NONE, ONEWAY, ONEWAY_LEFTFILTERSRIGHT or ONEWAY_RIGHTFILTERSLEFT.

Returns

Filter. No value of its own: it changes how the relationship filters, for the CALCULATE it is in.

Remarks

  • BOTH lets the relationship filter both ways: a filter on Places then reaches Products through Sales. NONE switches the relationship off. ONEWAY filters from the one side to the many side only, as a relationship does by default.
  • ONEWAY_LEFTFILTERSRIGHT and ONEWAY_RIGHTFILTERSLEFT name the filtering column by its place in the call. On a many-to-one relationship the one side must be the one that filters: asking the many side alone to filter is an error.
  • The two columns may come in either order.
  • It works only as a filter of CALCULATE or CALCULATETABLE, and the columns must be those of a relationship of the model; otherwise it is an error.
  • Write the direction as a keyword, without quotes.
  • Filtering both ways can make numbers harder to follow, and slower. Change it in the one measure that needs it rather than in the model.

Examples

Products sold at each kind of place

Normally a filter on Places does not reach Products, so every row sees all four products. With BOTH, it reaches them through Sales: the depot sold nothing, so no product is left.

EVALUATE
ADDCOLUMNS (
    VALUES ( Places[Kind] ),
    "Products", COUNTROWS ( Products ),
    "Products sold there",
        CALCULATE ( COUNTROWS ( Products ), CROSSFILTER ( Sales[Product], Products[Product], BOTH ) )
)
ORDER BY Places[Kind]
Places[Kind]ProductsProducts sold there
Depot4(blank)
Shop44

A relationship switched off

With NONE, the category of the row no longer reaches Sales: each row has every liter.

EVALUATE
SUMMARIZECOLUMNS (
    Products[Category],
    "Liters", [Liters sold],
    "Relationship off", CALCULATE ( [Liters sold], CROSSFILTER ( Sales[Product], Products[Product], NONE ) )
)
ORDER BY Products[Category]
Products[Category]LitersRelationship off
Beer15053891806463
Cider3010741806463

USERELATIONSHIP, CALCULATE, ALLCROSSFILTERED, ISCROSSFILTERED, TREATAS.

Last updated · OpenBI Studio 0.3.74