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

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
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.