Forum Discussion

René's avatar
René
Frequent Visitor
3 years ago
Solved

Find soonest data form second table

Dear fellow BI colleagues,   I am struggling to get the following to work, as shown in the image below. My intention is to list the date, supplier name, and quantity to be received for each Sales O...
  • johnt75's avatar
    3 years ago

    You could create a measure like

    Next expected date =
    VAR CurrentProduct =
        SELECTEDVALUE ( 'Sales Order'[Product] )
    VAR Supplier =
        MINX (
            TOPN (
                1,
                FILTER (
                    'PO Lines',
                    'PO Lines'[Product] = CurrentProduct
                        && 'PO Lines'[Expected date] >= TODAY ()
                ),
                'PO Lines'[Expected date], ASC
            ),
            'PO Lines'[Supplier]
        )
    RETURN
        Supplier
    

    and then repeat that for the other columns you want.