Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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)

 

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

     

     

    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
        )

     

     

    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.

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    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.

  • v-zhenbw-msft's avatar
    v-zhenbw-msft
    Icon for Community Support rankCommunity 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.

     

     

    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
        )

     

     

    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.

  • v-zhenbw-msft's avatar
    v-zhenbw-msft
    Icon for Community Support rankCommunity 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.