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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

USERELATIONSHIP doesn't work

I need a simple USERELATIONSHIP formula to work and I have no idea why it doesn't.

Please find an example here:

report

 

There are 2 tables with one active and one non-active relationship.

I've checked datatypes, the correctness of key columns and everything is correct.

The formula looks correct as well:

CALCULATION = CALCULATE(SELECTEDVALUE('DIM Rooms'[Used for]),USERELATIONSHIP('Room data'[Room # ADJUSTED],'DIM Rooms'[Room only]))
 

There is a calculation Column that should give provide a different result for room 3811, but it doesn't.

I tried a number of changes and none did help. 

1 ACCEPTED SOLUTION
AlB
Super User
Super User

@Anonymous 

Tricky. You could do something like this:

CALCULATION =
CALCULATE (
    CALCULATE ( DISTINCT ( 'DIM Rooms'[Used for] ), 'Room data' ),
    USERELATIONSHIP ( 'Room data'[Room # ADJUSTED], 'DIM Rooms'[Room only] ),
    ALL ( 'DIM Rooms' )
)

but it's quite complex. Best use LOOKUPVALUE:

CALCULATION V2 = 
LOOKUPVALUE( 'DIM Rooms'[Used for] , 'DIM Rooms'[Room only], 'Room data'[Room # ADJUSTED])

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

View solution in original post

7 REPLIES 7
AlB
Super User
Super User

@Anonymous 

Tricky. You could do something like this:

CALCULATION =
CALCULATE (
    CALCULATE ( DISTINCT ( 'DIM Rooms'[Used for] ), 'Room data' ),
    USERELATIONSHIP ( 'Room data'[Room # ADJUSTED], 'DIM Rooms'[Room only] ),
    ALL ( 'DIM Rooms' )
)

but it's quite complex. Best use LOOKUPVALUE:

CALCULATION V2 = 
LOOKUPVALUE( 'DIM Rooms'[Used for] , 'DIM Rooms'[Room only], 'Room data'[Room # ADJUSTED])

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Anonymous
Not applicable

Hi @AlB ,

 

Thank you for this!

Still, do you have an Idea why it might not work?

I'm trying to find a clue why this more complex formula suggested by you should be used.

 

Thank you.

 

@Anonymous 

Check this out

https://www.sqlbi.com/articles/userelationship-in-calculated-columns/

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

AlB
Super User
Super User

@Anonymous 

What is the expected resutl and why?

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Cheers 

 

SU18_powerbi_badge

Anonymous
Not applicable

Hey @AlB ,

In the "Room Data" table, the column "CALCULATION" should give "QQQ" for the "Room # Adjusted" value equal to 3811.

At least that's my understanding 🙂

AlB
Super User
Super User

Hi @Anonymous 

The link for the file requires logging into google. Can you remove the requirement? Or host the file somewhere else?

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Cheers 

 

SU18_powerbi_badge

Anonymous
Not applicable

I am really sorry about that. I removed any restrictions. It should work now.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.