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
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
m1ke909
7 years agoFrequent Visitor
Thanks for the help, it doesn't seem to qutie work and I think the issue is with the Type field which I've listed as ABC but it is actually 1, 2 or 3 as well as the hours and location being in two different sheets.
- AnthonyTilley7 years agoSolution Sage
Are you able to provide a sample PBIX file
- m1ke9097 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.