Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
felipekrebs
Helper I
Helper I

Helps sort BD and create data model

I didn't really know where to place the post to if I leave the link for them to see:

https://community.powerbi.com/t5/Desktop/Ayuda-crear-modelo-de-datos/td-p/1443161

In short, I need to keep track of logistical costs and I have 2 tables, the problem arises when I want to connect them and not be able to bring all the fields that I want without being alerted that "no connections"

-Table 1: Table with all sales orders (PV) with their respective values of each (each PV is unique)

-Table 2: logistical cost table, there can be more than 1 logistical cost (more than one line) for each PV

When generating my measurements I get the error that it does not sum the values well, or does not generate the indicated.

That's why I need your help, if I need to create another BD or more tables to better sort the information, I would appreciate your advice, I am also available so that you can advise me more privately or we can meet in a virtual meeting a little bit for velro in more detail. (contact me at wsp +569 81598377)

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

Hi @felipekrebs ,

First, make sure that a relationship based on the field [PV] is created between Table 1 and Table 2. Then, you can create a measure  to get it as follows:

Cost of per kg = 
VAR _curpv =
    MAX ( 'Table 1'[PV] )
VAR _sumofcost =
    CALCULATE (
        SUM ( 'Table 2'[costo] ),
        FILTER ( 'Table 2', 'Table 2'[PV] = _curpv )
    )
RETURN
    DIVIDE ( _sumofcost, MAX ( 'Table 1'[Kilos] ) )

Helps sort BD and create data model.JPG

If the above one can't get the correct value, please provide your expected result and the related calculation logic. Thank you.

Best Regards
Rena
Community Support Team _ Rena Ruan
If this post helps, then please consider Accept it as the solution to help the other members find it more.

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

View solution in original post

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

Hi @felipekrebs ,

First, make sure that a relationship based on the field [PV] is created between Table 1 and Table 2. Then, you can create a measure  to get it as follows:

Cost of per kg = 
VAR _curpv =
    MAX ( 'Table 1'[PV] )
VAR _sumofcost =
    CALCULATE (
        SUM ( 'Table 2'[costo] ),
        FILTER ( 'Table 2', 'Table 2'[PV] = _curpv )
    )
RETURN
    DIVIDE ( _sumofcost, MAX ( 'Table 1'[Kilos] ) )

Helps sort BD and create data model.JPG

If the above one can't get the correct value, please provide your expected result and the related calculation logic. Thank you.

Best Regards
Rena
Community Support Team _ Rena Ruan
If this post helps, then please consider Accept it as the solution to help the other members find it more.

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.