Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Fill table based on information according to date.

Hello,    I'm currently having dificultes in fiding a way to do this.    Basically I have two tables, one with the order information:  Product  Date Material O1 01/01/2022 Iron  O2 ...
  • Sahir_Maharaj's avatar
    3 years ago

    Hello Anonymous,

     

    Supplier = 
    VAR CurrentDate = Orders[Date]
    VAR Material = Orders[Material]
    RETURN
    CALCULATE(
        FIRSTNONBLANK(Suppliers[Supplier], 1),
        Suppliers[Supplies] = Material,
        Suppliers[ContractDateLimit] >= CurrentDate
    )

     

    This formula uses a combination of the CALCULATE, FIRSTNONBLANK, and VAR functions to create a new column called "Supplier" in the Orders table. It looks up the supplier that supplies the material for each order and that has an active contract as of the order date.

     

    Let me know if you might need further assistance.