Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
TheLoonies
Frequent Visitor

Selecting which relationships and filters to use with DAX

Hi,

 

I want to create a report which allows the user to select some group from within the dataset and then a subgroup from within that group and use aggregations of the group and subgroup to create measures

 

for example:

 

If the data is fresh produce, then the user can select "fruit" as the group and "oranges" as the subgroup and then it might calculate (sales of oranges )/ (sales of fruit); the percentage of fruit sales which were oranges

 

or they could pick: "fruit and vegetables" as the group and "oranges" as the subgroup

or "fruit and vegetables" as the group and "fruit" as the subgroup. In each example I want to have returned the subgroup as a percentage of the group.

 

I thought it was important that the user can only select subgroups which are contained within the group so I set up relationships as follows:

 

TheLoonies_0-1685424289323.png

This allows the slicers in the report to function sufficiently close to how I want.

 

Now I want to create measures such as:

 

NumberPOsMacro = CALCULATE(
    DISTINCTCOUNT(PurchaseOrder_ProductEntity[PurchaseOrderID]),
    USERELATIONSHIP('Product_Entity'[EntityID], 'Entity Macro'[EntityID])
    )
 
The issue is that this doesn't work, it doesn't appear to use the correct relationship.
 
Manually modifying the relationships sometimes works:
 
TheLoonies_2-1685424997395.png

This makes sense, in the case where it fails the filters from the subgroup are still applying while in the case where it works they don't.

 

I assume that it doesn't work because USERELATIONSHIP is disabling the relationships in a way which matches the fail case.

 

adding REMOVEFILTERS as so:
 
NumberPOsMacro = CALCULATE(
    DISTINCTCOUNT(PurchaseOrder_ProductEntity[PurchaseOrderID]),
    REMOVEFILTERS('Entity Micro'),
    USERELATIONSHIP('Product_Entity'[EntityID], 'Entity Macro'[EntityID])
    )
 
Also doesn't work, it successfully removes the filters but it also disables the USERELATIONSHIP.
 
How can I get the measures to use the relationships as configured in the image above under works? If that's not adviseable, how can I get this report to function as intended in an alternative way?
 
Here is the entire model for reference:
 
TheLoonies_3-1685425994737.png

 

Thanks.

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@TheLoonies 
Please try

NumberPOsMacro =
CALCULATE (
    DISTINCTCOUNT ( PurchaseOrder_ProductEntity[PurchaseOrderID] ),
    CROSSFILTER ( 'Entity Macro'[EntityID], 'Entity Micro'[EntityID], NONE ),
    USERELATIONSHIP ( 'Product_Entity'[EntityID], 'Entity Macro'[EntityID] )
)

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

@TheLoonies 
Please try

NumberPOsMacro =
CALCULATE (
    DISTINCTCOUNT ( PurchaseOrder_ProductEntity[PurchaseOrderID] ),
    CROSSFILTER ( 'Entity Macro'[EntityID], 'Entity Micro'[EntityID], NONE ),
    USERELATIONSHIP ( 'Product_Entity'[EntityID], 'Entity Macro'[EntityID] )
)

this didn't work, but 

 

NumberPOsMacro = CALCULATE (
    DISTINCTCOUNT ( PurchaseOrder_ProductEntity[PurchaseOrderID] ),
    CROSSFILTER ( 'Entity Micro'[EntityID], 'Product_Entity'[EntityID], NONE ),
    USERELATIONSHIP ( 'Product_Entity'[EntityID], 'Entity Macro'[EntityID] )
)
 
did.
 
thanks so much for your help!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.