THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | |
in Search

SQLBI - Marco Russo

SQLBI is a blog dedicated to building Business Intelligence solutions with SQL Server.
You can follow me on Twitter: @marcorus

Leverage INTERSECT to apply relationships in DAX

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.

Published Tuesday, July 26, 2016 10:47 AM by Marco Russo (SQLBI)

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Bogdan said:

using the suggested formula with calculate & intersect looks very good - but every time I try to author such formula excel (powerpivot) crashes... This was a know problem before https://support.microsoft.com/en-us/kb/3114297

but it is still there. Can not use these two functions in one measure...

September 15, 2016 11:08 AM
 

Marco Russo (SQLBI) said:

Strange - is it working now? (I know, it was an old comment, sorry for delay, I missed notifications).

January 19, 2017 2:07 PM

Leave a Comment

(required) 
(required) 
Submit

About Marco Russo (SQLBI)

Marco Russo is a consultant, writer and trainer specialized in Business Intelligence with Microsoft technologies. He runs the SQLBI.COM website, which is dedicated to distribute resources useful for BI developers, like Integration Services components, Analysis Services models, tools, technical information and so on. Marco is certified as MCT, MCDBA, MCSD.NET, MCSA, MCSE+I.

This Blog

Syndication

Archives

Privacy Statement