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
Anonymous
Not applicable

Id with multiple values

Hello, currently I have tow tables: contracts and Units (building units) related by ContractID, and based on the final date of the contract, I have calculated if that specific contractID is currently with a tenant or vacant, thus letting me see which units are vacant or not.
The problem is that one unit could have had multiple contracts over time and therefore it would show the unit duplicated with both vacant and with tenant values:

RodrigoGM_0-1656057077216.png

Im not being able to come up with a way to, when having a unitID with multiple contracts, just keep the one that has the last enddate without losing the ones that are vacant (contracts have expired)

 

Could you help me?

 

Thank you!

4 REPLIES 4
SpartaBI
Community Champion
Community Champion

@Anonymous you have a scenario of many to many relationship (not to be confused with many to many cardinality which is much less complicated scenario). You need a bridge table with unique combinations of contract and units between these two tables. This is a technique you need to learn, but I got you. Start with this free video by SQLBI.COM: https://www.youtube.com/watch?v=wRSJ6TYjEu0
If you need more look for everything you can from sqli regarding this, they have everything and explained in the best way.
 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

Anonymous
Not applicable

Hi, thanks for your response, im not sure though that this is a many to many relationship, since a unit can have multiple contracts but there cant be a contract with multiple units.

 

In the end, what I think its needed is a way to filter that when an unitID has multiple values, just filter the one with the latest enddate. I cannot come up with the dax way of doing it even though it doesnt sound that hard.

😐

oh, so no. it's not a many to many 🙂
So I don't understand the issue :))
Can you maybe share a sample PBIX and explain there hard coded the desired result?

Anonymous
Not applicable

So basically, what i want is to display a table in which I can see all units (building units) and see if they are currently vacant or with a tenant (based on the enddate of their contract/ this is done).

 

As of right now, I have a table in which I can see all units, but some are dupliacted showing both the value vacant and with tenant, which happens because they used to have a tenant, whos contract expired, and then a new one entered (example: unit 007 in table below).

RodrigoGM_0-1656066138388.png

The thing is, that if I filter by enddate (lets say, enddate after today), then the table will stop displaying the units that are vacant., since they currently have no contract in place.

 

So, the desired end result would be to display all units, based on their last contract ( so no dupliacted values).

 

Dont know if this is helpfull.

 

Thanks again!

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.