Forum Discussion

m1ke909's avatar
m1ke909
Frequent Visitor
7 years ago
Solved

2 Criteria look up

New to power BI here but slowly picking it up,    I'm trying to complete a two criteria look up like the example below.   Two data fields to pick from so it displays the correct template set. Yel...
  • AnthonyTilley's avatar
    7 years ago

    There might be an easier way to do this but this one worked for me 

     

    template = 
    var T = GreenTable[Type]
    var gh = GreenTable[Hours]
    var h = CALCULATE(MINX(YellowTable,ABS(YellowTable[Hours]-gh)),YellowTable[Location Type]=t)
    Var h2 = LOOKUPVALUE(YellowTable[Hours],YellowTable[Hours],gh + h)
    Var h3 = if(h2 = blank(), LOOKUPVALUE(YellowTable[Hours],YellowTable[Hours],gh - h), h2)
    Var Template = CALCULATE(max(YellowTable[Template]),YellowTable[Location Type] = t, YellowTable[Hours] = h3)
    
    return Template