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

Measure from 2 tables

Hi. I have 2 tables, order_lines and order_create_purchase_price. I have a relationship between id and order_lines_id.

 

What I need to calculate is order_create_purchase_price.purchase_price * order_lines.quantity - order_create_purchase_price.VAT(this is tax% from price), so I can get purchase price from all without tax. Any help?

 

order_lines table

idquantityprice
43336812,5
43336921,5

 

order_create_purchase_price table

order_lines_idpurchase_pricevat
4333683,510
4333692,3510

 

I have this measure when I count something from 1 table without tax(here 'alv'), but I can't handle it with 2 tables.

 

RivisummaAlv0 = round(SUMX ( 'order_lines',divide( [price] * ( [quantity] )*1.0 ,(1 + [alv] /100.0))),2)

 

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

What is the relationship between your tables, one-to-many, one-to-one, or many-to-many?

 

Do you want to calculate the purchase_price* quantity - purchase_price* quantity*( vat/100)?

For example, the id 433681 calculates 35 * 1 – 35 * 1 * (10 / 100) = 32

If yes, we create a one-to-one relationship based on your sample data.

 

M1.jpg

 

Then we can create a measure to get the result.

 

Measure = 
SUM ( order_create_purchase_price[purchase_price] )
    * SUM ( order_lines[quantity] )
    * (
        1
            - SUM ( order_create_purchase_price[vat] ) / 100
    )

 

M2.jpg

 

If it doesn’t meet your requirement, could you please provide a mockup sample based on fake data or describe the fields of each tables and the relations between tables simply?

It will be helpful if you can show us the exact expected result based on the tables.

 

Please upload your files to OneDrive For Business and share the link here. Please don't contain any Confidential Information or Real data in your reply.

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

View solution in original post

3 REPLIES 3
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

How about the result after you follow the suggestions mentioned in my original post?

Could you please provide more details or expected result about it If it doesn't meet your requirement?

If you've fixed the issue on your own please kindly share your solution. If the above posts help, please kindly mark it as a solution to help others find it more quickly.

 

Best regards,

 

Community Support Team _ zhenbw

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

v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

What is the relationship between your tables, one-to-many, one-to-one, or many-to-many?

 

Do you want to calculate the purchase_price* quantity - purchase_price* quantity*( vat/100)?

For example, the id 433681 calculates 35 * 1 – 35 * 1 * (10 / 100) = 32

If yes, we create a one-to-one relationship based on your sample data.

 

M1.jpg

 

Then we can create a measure to get the result.

 

Measure = 
SUM ( order_create_purchase_price[purchase_price] )
    * SUM ( order_lines[quantity] )
    * (
        1
            - SUM ( order_create_purchase_price[vat] ) / 100
    )

 

M2.jpg

 

If it doesn’t meet your requirement, could you please provide a mockup sample based on fake data or describe the fields of each tables and the relations between tables simply?

It will be helpful if you can show us the exact expected result based on the tables.

 

Please upload your files to OneDrive For Business and share the link here. Please don't contain any Confidential Information or Real data in your reply.

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

Greg_Deckler
Super User
Super User

@Anonymous - Use RELATED or RELATEDTABLE. Please post sample data as text and expected output from sample data and can be more specific.

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.