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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jagan2678
Frequent Visitor

Using Userelationship in Allselected

This is my measure, 
Include all selections? =
VAR _selected =
    ALLSELECTED ( 'dim'[year] )
VAR _options =
    CALCULATE (
        DISTINCTCOUNT ( 'hotel'[year]  ),
        FILTER (
            ALLSELECTED ( 'hotel' ),
            'hotel'[hotel] = MAX ( 'hotel'[hotel] )
                && 'hotel'[year] IN _sel
        )
    )
 
RETURN
    IF ( COUNTROWS ( _selected ) = _options, 1, 0 )
 

The data model is 

jagan2678_0-1667286399851.png

 


Column year of the office table is already in an active relationship with colum year of the dimdate table.

 

Here im trying to use the dim[year] which is an inactive one to many relation with hotel[year]. But since its in an inactive relation im not able to compare the output of allselected of dim[year] with the hotel[year] as in the measure. let me know how to solve this.
5 REPLIES 5
Anonymous
Not applicable

Hi @jagan2678 ,

 

I create a sample to have a test by your code.

Hotel:

RicoZhou_0-1667281528229.png

Dim:

RicoZhou_1-1667281550838.png

Relationship:

RicoZhou_2-1667281615224.png

Result is as below.

RicoZhou_3-1667281656942.png

If this is not the solution you need, please show me a screenshot with the result you want. This will make it easier for me to find the solution.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

jagan2678_0-1667286431347.png

 

this is my data model.. so as per this, i already have an active relationship between year column of office table with dimdate table..

 

so my challeneg is to use my measure which was created to perform AND logic in slicers to use an inactive relationship in the allselected function.

Anonymous
Not applicable

Hi @jagan2678 ,

 

According to your screenshot, I think there are an active relationship between DimDate and hotel. So when you filter on DimDate slicer, the relationship will impact the columns from hotel. I suggest you to create a new unrelated DimDate2 table to achieve your goal.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

sorry there was a correction in my data model. i have updated the data model correctly now. can u suggest for this.

jagan2678_1-1667286487551.png

 

amitchandak
Super User
Super User

@jagan2678 , first have a measure with userelationship and then use allselected

 

 

CALCULATE( CALCULATE(SUM(Table[Value]),USERELATIONSHIP('Table'[Date],[Date])),allselected(Table))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors