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

Substract values from different tables

Hi,

i have 2 tables.  T_USRBARCODE is common variable.  in table1 a have column PN class Number and in second table i have column I_CLASS.
Now, want to subtract one value from another (PN class Number- I_CLASS), so the result would be, in case from picture:

1. row --->1
2. row --->0
3. row --->2

4. row --->2

5. row --->1  ect.

Capture.PNG
i tried measure=sum(table1[PN class Number])-sum(table 2[I_CLASS]) and also tried with CALCULATE funtion but nothing worked.

Pls help me with this.

 

Tnx

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can create a bridge table include the 'code' column to change many-to many relationship into many-to-one relationship between two tables because many-to-many relationship cannot find the unique value which corresponds with each rows.

many-to-one.png

table result.png

 

Refer this microsoft document:

Apply many-many relationships in Power BI Desktop 

 

Best Regards,
Yingjie Li

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

Anonymous
Not applicable

Both table are created as result of merging tables that are in direct query mode. So every time i refresh i get new 'codes'. Problem is that sql server, on which i am connected with diect query, is filled by operators in production and there is always some percent of wrong entryes. And in that case i wont always have 1-1 in codes. What hapens to codes that don't have counterparts?

 

How goes the measure you have writen for subtracting?

parry2k
Super User
Super User

@Anonymous relationship between these tables is 1 to 1 or 1 to many, share screenshot of relationship diagram?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Relation is many to many

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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!

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