Forum Discussion
m1ke909
7 years agoFrequent Visitor
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...
- 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
AnthonyTilley
7 years agoSolution Sage
Are you able to provide a sample PBIX file
m1ke909
7 years agoFrequent Visitor
Not to worry, I made a slight tweak and got it working.
Thank you!
- AnthonyTilley7 years agoSolution Sage
Great make sure to mark the thread as solved.
- m1ke9097 years agoFrequent Visitor
Thank you again.
I'm trying to duplicate the above code to return a slightly different field.
I want the exact same code but returning 3 different colums, do the Variable all need to be renamed?
As whenever I try to copy it I get and error 'circular dependancy'.