Cross filter direction
This option determines the direction in which filters flow. For many-to-one and one-to-many relationships, you can select Single or Both:
- If you select Single, then the filters from the table on the “one” side will filter through to the table on the “many” side. This setting is signified by a single arrowhead on the relationship line in the Model view.
- If you select Both, then filters from both tables will flow in both directions; such relationship are known as bidirectional. This setting is signified by two arrowheads on the relationship line in the Model view, facing in opposite directions. When this option is selected, you can also select Apply security filter in both directions to make row-level security filters flow in both directions too.
When editing table relationships, even if you set the relationship cross-filter direction to Both, by default the security filters are only applied in one direction. We noted that there’s an option to control security filtering called Apply security filter in both directions. This means that role filtering applied to a table will also be passed to the filtered table. When this option is disabled, only the table with filtered applied will be affected. This option exists because applying security filters affects the performance of your data model, so in some cases applying it may be undesirable.
Note Security Filters
Security filters refers to row-level security (RLS), a feature in Power BI that allows you to restrict access to data within a dataset based on a set of filters. We review row-level security in detail later in this chapter.
To illustrate how the cross-filter direction works, consider the data model shown in Figure 2-5.
FIGURE 2-5 Sample data model
From this data model, you can create two table visuals as follows:
- Table 1: Distinct count of Stock Item by Year
- Table 2: Distinct count of Year by Stock Item
Both table visuals are shown in Figure 2-6. The first four rows are shown for Table 2 for illustrative purposes.
FIGURE 2-6 Table visuals
You can see that in Table 1, the numbers are different for different years and the total, whereas in Table 2, the Distinct Count of Year is showing 6 for all rows, including the Total.
The numbers are different in Table 1 because filters from the Date table can reach the Stock Item table through the Sale table; the Date table filters the Sale table because there is a one-to-many relationship; then the Sale table filters the Stock Item table because there is a bidirectional relationship. In 2019, 2020, and 2021, Wide World Importers coincidentally sold 219 stock items, whereas in 2022, they sold 227 stock items. At the total level you see 228, which is not the total sum of stock items sold across all years. Importantly, the total 228 is showing as the distinct count of stock items when filters from the Date table are not applied.
In Table 2, the numbers are the same because filters from the Stock Item table don’t reach the Date table as there is no bidirectional filter. Even though Wide World Importers only had sales in four years, you see 6 across all rows, which is the number of years in the Date table.
It’s also possible to set the cross-filter direction by using the CROSSFILTER function in DAX, as you can see in this example:
Click here to view code image
Stock Items Sold =
CALCULATE(
DISTINCTCOUNT(‘Stock Item'[Stock Item]),
CROSSFILTER(
Sale[Stock Item Key],
‘Stock Item'[Stock Item Key],
BOTH
)
)
The syntax of CROSSFILTER is similar to USERELATIONSHIP—the first two parameters are related columns. Additionally, there’s the third parameter—direction—and it can be one of the following:
- BOTH This option corresponds to Both in the relationship cross-filter direction options.
- NONE This option deactivates the relationship, and it corresponds to the cleared Make this relationship active check box.
- ONEWAY This option corresponds to Single in the relationship cross-filter direction options.
Bidirectional filters are sometimes used in many-to-many relationships with bridge tables when direct many-to-many relationships are not desirable.
Need More Review? Bidirectional Relationships
For more examples and information on bidirectional relationships, see “Bi-directional relationship guidance” at https://docs.microsoft.com/en-us/power-bi/guidance/relationships-bidirectional-filtering.
Need More Review? Relationships Troubleshooting
Relationships may not work as expected for numerous reasons. For a comprehensive troubleshooting guide, see “Relationship troubleshooting guidance” at https://docs.microsoft.com/en-us/power-bi/guidance/relationships-troubleshoot.