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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

USERELATIONSHIP when certain value is selected

Julkku_1-1636043804572.png

 

Hi,

 

I'm filtering table Person ID with the Field of business dimensional table. If one specific field (for example Field 1) is selected we want to filter every person ID on every company. But in case the selection is "Similar" we should only get a list of person ID's who belong to any company that is similar for the selected company.

 

I wonder if there is a way to build a measure that activates the inactive relation between Company 2 and Person ID whenever "Similar" is selected.

 

Thanks in advance!

 

Julia

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

You could write a measure with two variables - one with USERELATIONSHIP and one without, and then use IF with SELECTEDVALUE on your slicer column to decide which to return.

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

5 REPLIES 5
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, I create a sample, the measure is just like you wrote.

vkalyjmsft_0-1636437597524.jpeg

When I drag it into the values, and select “similar”, it can work fine like other fields.

vkalyjmsft_1-1636437597528.jpeg

Here’s my sample bellow.

 

Best Regards,
Community Support Team _ kalyj

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

Anonymous
Not applicable

Thanks @v-yanjiang-msft! Your answer made me realize my model wasn't following exactly the picture attached. After making some relation changes the report started to work as I had hoped. Thanks for making such a huge effort 🙂

Anonymous
Not applicable

Thanks, your solution moved me forward but I still need some additional guidance. This is how my measure worked out:

 

Measure = 
var _similar = CALCULATE(DISTINCTCOUNT('PERSON ID'[id]), USERELATIONSHIP(PERSON ID[id], Company2[Id]))
var _all = CALCULATE(DISTINCTCOUNT('PERSON ID[id])

RETURN

CALCULATE(IF(SELECTEDVALUE(Field of Business[key]) = "Similar", _similar, _all))

 

The problem is, I only get the calculated amount of similar id's but it is not possible to use them as row values. In the Person ID table I have additional information, such as gender. I'd like to visualize how id's within each and every selection are divided into men and women.

 

When I select any other field than "Similar", the column chart works perfectly. When selecting "Similar", the visualization is turning all white. 

 

Do you have an idea how this could be fixed?

Anonymous
Not applicable

Does anybody have an idea how to fix this? 🙂 

mahoneypat
Employee
Employee

You could write a measure with two variables - one with USERELATIONSHIP and one without, and then use IF with SELECTEDVALUE on your slicer column to decide which to return.

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.