Forum Discussion

Bondeuz's avatar
Bondeuz
Frequent Visitor
2 years ago
Solved

Need help with relationship between tables

Hi,

 

I am trying to calculate the difference in run time based on the calculated run time and the actual run time on a production order.

 

The data on the actual run time comes from a "CapacityTransaction" table, and the data for the calculated time comes from a "ItemRoutingRows" table. I am having trouble connecting these two tables in order to compare the two.

 

Below is sample data from the two tables, when I am trying to connect the tables by "Routing_No" i can just get a "Many to Many" relationship which then sums up the total calculated run time for all the rows on an item and displays the total time instead of each individual time on each row.

 

ItemRoutingRows Table below,

Routing_NoOperation_NoTypeNoDescriptionRouting_Link_CodeRun_Time
10098-0510Work CenterFUSEFormlabs Fuse 1 SLS PrinterSLS0.177
10098-0520Work CenterGBGlasblästringBLÄSTER0.007
10098-0530Work CenterIFGInfärgningINFÄRG0.001
10098-0540Work CenterVMIKvalitetskontrollKVAL0.002
10098-0550Work CenterBEARBBearbetning SLSBEARB

0.02

 

CapacityTable below,

Document_NoRouting_NoOperation_NoTypeNoDescriptionRun_Time
PS00616910098-0510Work CenterFUSEFormlabs Fuse 1 SLS Printer40
PS00616910098-0520Work CenterGBGLASBLÄSTRING2
PS00616910098-0530Work CenterIFGInfärgning0.6
PS00583910098-0510Work CenterFUSEFormlabs Fuse 1 SLS Printer23
PS00583910098-0520Work CenterGBGLASBLÄSTRING1
PS00583910098-0530Work CenterIFGInfärgning0.3
PS00583910098-0540Work CenterQCKvalitetskontroll0.2
PS00583910098-0550Work CenterBEARBBearbetning SLS0.4
PS00525610098-0510Work CenterFUSEFormlabs Fuse 1 SLS Printer23
PS00525610098-0520Work CenterGBGLASBLÄSTRING1
PS00525610098-0530Work CenterIFGInfärgning0.3
PS00525610098-0540Work CenterQCKvalitetskontroll0.2
PS00525610098-0550Work CenterBEARBBearbetning SLS1

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, Bondeuz 

     

    Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

     

    Measure:

     

    Operation_No1 =
    
    CALCULATE ( MAX ( CapacityTransaction[Operation_No] ) )
    
    
    
    No1 =
    
    CALCULATE ( MAX ( CapacityTransaction[No] ) )
    
    Run_Time1 =
    
    CALCULATE ( MAX ( CapacityTransaction[Run_Time] ) )
    
    
    
    
    
    Time_Diff =
    
    VAR CurrentOperation = CapacityTransaction[Operation_No1]
    
    VAR CurrentNo = CapacityTransaction[No1]
    
    VAR CurrentRunTime = CapacityTransaction[Run_Time1]
    
    VAR RelatedRow =
    
        CALCULATETABLE (
    
            ItemRoutingRows,
    
            ItemRoutingRows[Operation_No] = CurrentOperation,
    
            ItemRoutingRows[No] = CurrentNo
    
        )
    
    VAR RelatedRunTime =
    
        MAXX ( RelatedRow, ItemRoutingRows[Run_Time] )
    
    RETURN
    
        CurrentRunTime - RelatedRunTime

     


    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

     

     

2 Replies

  • Bondeuz , You can create a new column in both tables and join. Seem like this combined columns are key for table 1

     

    Key - combinevalues("-",[Routing_No], [Operation_No])

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Bondeuz 

     

    Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

     

    Measure:

     

    Operation_No1 =
    
    CALCULATE ( MAX ( CapacityTransaction[Operation_No] ) )
    
    
    
    No1 =
    
    CALCULATE ( MAX ( CapacityTransaction[No] ) )
    
    Run_Time1 =
    
    CALCULATE ( MAX ( CapacityTransaction[Run_Time] ) )
    
    
    
    
    
    Time_Diff =
    
    VAR CurrentOperation = CapacityTransaction[Operation_No1]
    
    VAR CurrentNo = CapacityTransaction[No1]
    
    VAR CurrentRunTime = CapacityTransaction[Run_Time1]
    
    VAR RelatedRow =
    
        CALCULATETABLE (
    
            ItemRoutingRows,
    
            ItemRoutingRows[Operation_No] = CurrentOperation,
    
            ItemRoutingRows[No] = CurrentNo
    
        )
    
    VAR RelatedRunTime =
    
        MAXX ( RelatedRow, ItemRoutingRows[Run_Time] )
    
    RETURN
    
        CurrentRunTime - RelatedRunTime

     


    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum