cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Partisan
Post Partisan

Using two or more USERELATIONSHIPs

Hi experts,

 

I am trying to sum Quantity by GroupName in the following relationship scenario. Tables are related via the same name fields.

 

Sales.jpg

 

This is simplified part of a much more complicated relationship scheme in which I can not have active relationships between these three tables. However, I read that one can use nested USERELATIONSHIP instructions. How do I do that?

 

Thank you.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Using two or more USERELATIONSHIPs

Hi @gvg

 

From the tables/relationships you've shown, you should just activate the two relationships simultaneously.

 

The measure should look something like:

 

=
CALCULATE (
    SUM ( Sales[Quantity] ),
    USERELATIONSHIP ( Sales[Product], Subgroup[Product] ),
    USERELATIONSHIP ( Subgroup[SubgroupName], Group[SubgroupName] )
)

 

You can also use the CROSSFILTER function with the same effect:

 

 

=
CALCULATE (
    SUM ( Sales[Quantity] ),
    CROSSFILTER ( Sales[Product], Subgroup[Product], OneWay ),
    CROSSFILTER ( Subgroup[SubgroupName], Group[SubgroupName], OneWay )
)

Owen 🙂


Owen Auger

Did I answer your question? Mark my post as a solution!

Connect on Twitter
Connect on LinkedIn

View solution in original post

2 REPLIES 2
Highlighted
Community Champion
Community Champion

Re: Using two or more USERELATIONSHIPs

Hi @gvg

 

From the tables/relationships you've shown, you should just activate the two relationships simultaneously.

 

The measure should look something like:

 

=
CALCULATE (
    SUM ( Sales[Quantity] ),
    USERELATIONSHIP ( Sales[Product], Subgroup[Product] ),
    USERELATIONSHIP ( Subgroup[SubgroupName], Group[SubgroupName] )
)

 

You can also use the CROSSFILTER function with the same effect:

 

 

=
CALCULATE (
    SUM ( Sales[Quantity] ),
    CROSSFILTER ( Sales[Product], Subgroup[Product], OneWay ),
    CROSSFILTER ( Subgroup[SubgroupName], Group[SubgroupName], OneWay )
)

Owen 🙂


Owen Auger

Did I answer your question? Mark my post as a solution!

Connect on Twitter
Connect on LinkedIn

View solution in original post

Highlighted
Post Partisan
Post Partisan

Re: Using two or more USERELATIONSHIPs

Thanks! It works. Except that Groups table name should be in quotes ('Groups') as it probably represents DAX keyword.

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors