Forum Discussion

Myshydde's avatar
Myshydde
Frequent Visitor
3 years ago
Solved

Help witch fetching values from another table depending on conditions

Hi I’m new do DAX and PowerBI and trying to get the hang of it, but I’m stuck. I will try to the best of my abilities describe what I need to do. I would like to create a new column in my datatable ...
  • SomeDataDude's avatar
    3 years ago

    Hi Myshydde ,

     

    If I understand you’re question. You’re looking for something like this?

     

     

  • SomeDataDude's avatar
    SomeDataDude
    3 years ago

    I add an extra search value in the LOOKUPVALE() to match the first criteria. In the first line were checking the rule code and supplier, if they match with Data[Code]. We return the NewCategory. Otherwise the DefaultCategory.

    Example:

        IF(
            LOOKUPVALUE(Rules[Code], Rules[SupplierIDCode], Data[SupplierIDCode], Rules[SupplierID], Data[SupplierID]) = Data[Code]
            ,
            LOOKUPVALUE(Rules[NewCategory],Rules[Code],Data[Code]) & "From Rules"
            ,
            LOOKUPVALUE(Suppliers[DefaultCategory],Suppliers[SupplierID],Data[SupplierID])
        )