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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
bvy
Helper V
Helper V

Constant Measure breaking my One-to-Many Relationship - Why?

Very simple data model and report here to demonstrate my issue. I have a Person table and a City table with a one-to-many relationship on CityID as shown below. I entered the data manually. 

 

bvy_1-1664634714810.png

 

I've added MyMeasure to the Person table that just returns a constant value. 

 

bvy_2-1664634967991.png

 

My report has a slicer on Name, and two table visuals to illustrate the issue.
Table1 - Without MyMeasure in the table, it works as expected. It shows the selected user name with their city name. 

Table2 - Whenever I add MyMeasure to the table, it ignores the relationship and returns the selected user associated with ALL cities. 

 

bvy_4-1664635620134.png

 

What is the simplest modification I can make here to correct the issue? Thank you. 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@bvy Maybe:

 

MyMeasure = 
    VAR __CityID = MAX('Person'[CityID])
    VAR __CityID2 = MAX('City'[CityID])
RETURN
    IF(__CityID = __CityID2, "Active",BLANK())

As for why, it is because you coded your measure as a constant. So every row will return that constant value for your measure and thus your current results.

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
bvy
Helper V
Helper V
Greg_Deckler
Super User
Super User

@bvy Maybe:

 

MyMeasure = 
    VAR __CityID = MAX('Person'[CityID])
    VAR __CityID2 = MAX('City'[CityID])
RETURN
    IF(__CityID = __CityID2, "Active",BLANK())

As for why, it is because you coded your measure as a constant. So every row will return that constant value for your measure and thus your current results.

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler and thanks for taking time to look at this with me... 

 

I see where you're heading with this, but your proposed change doesn't work. I've tried some variations also, and they don't work either. See below...

 

bvy_0-1664652118957.png

 

@bvy Likely incorrect configuration of the visual or a difference in relationships. City should come from the City table and Name from the Person table. Take a look at the PBIX attached below signature, working great there.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

You were right. I had changed the relationsship to two way and forgot to send it back. Appreciate the help. 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.