Quantcast
Channel: SQLBI
Viewing all articles
Browse latest Browse all 434

Leverage INTERSECT to apply relationships in DAX

$
0
0

If you are used to virtual relationships in DAX (see Handling Different Granularities in DAX), you probably use the following pattern relatively often:

[Filtered Measure] :=
CALCULATE(
    <target_measure>,
    FILTER(
        ALL(<target_granularity_column> ),
        CONTAINS(
            VALUES(<lookup_granularity_column> )
            <lookup_granularity_column>,
            <target_granularity_column> 
        )
    )
)

In the new DAX available in Excel 2016*, Power BI Desktop, and Analysis Services 2016, you can use a simpler syntax, which offers a minimal performance improvement and is much more readable:

[Filtered Measure] :=
CALCULATE(
    <target_measure>,
    INTERSECT(
        ALL(<target_granularity_column> ),
        VALUES(<lookup_granularity_column> )
    )
)

You can find a longer explanation of this new pattern and download some examples in the new article Physical and Virtual Relationships in DAX, on SQLBI web site.


Viewing all articles
Browse latest Browse all 434

Trending Articles