Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How do I create the relationships

Hi,   I am new to PowerBi and currently stuck on the relationship between the tables below.   Orders   Stock Allocation   Power Bi Desktop   How to create the relationship...
  • v-xiaotang's avatar
    v-xiaotang
    4 years ago

    Hi Anonymous 

    You can try this,

    (1) Create the auxiliary tables

    Table = DISTINCT( SELECTCOLUMNS(Orders,"Sales Date",Orders[Sales Date],"Order",Orders[Order]))

    (2) create the measures below,

    Qty = 
    CALCULATE (
        SUM ( Orders[Qty] ),
        FILTER (
            ALL ( Orders ),
            Orders[Branch] = SELECTEDVALUE ( 'Branch Filter'[Branch] )
                && Orders[Sales Date] = MIN ( 'Table'[Sales Date] )
                && Orders[Order] = MIN ( 'Table'[Order] )
        )
    )
    Allocation = 
    CALCULATE (
        SUM ( 'Stock Allocation'[Qty] ),
        FILTER (
            ALL ( 'Stock Allocation' ),
            'Stock Allocation'[Branch] = SELECTEDVALUE ( 'Branch Filter'[Branch] )
                && 'Stock Allocation'[Sales Date] = MIN ( 'Table'[Sales Date] )
                && 'Stock Allocation'[Order] = MIN ( 'Table'[Order] )
        )
    )

    result

    Best Regards,

    Community Support Team _Tang

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