Forum Discussion
Kavithaa
3 years agoNew Member
Lookup with mutiple table - If else loop condition
I have 2 tables as below. I have to create a new coloumn in "PO Table" - The value should be looked up from "Org Table". Requester has to be looked wiht "Org Table - Engineer", then whatever the ent...
- 3 years ago
Not sure what is the output you are looking for ?
Check this sample, if this is what you are looking for ...
Source: PO Table and Org Tables:
Relationships:
Measure:
Requester Level = var _sel = SELECTEDVALUE('PO Table'[Requester]) var _LevelID = SWITCH( TRUE(), -- is Engineer? LOOKUPVALUE('Org Table'[L4 ID], 'Org Table'[Engineer], _sel) <> BLANK(), LOOKUPVALUE('Org Table'[L4 ID], 'Org Table'[Engineer], _sel), -- is team leader LOOKUPVALUE('Org Table'[L3 ID], 'Org Table'[Team Leader], _sel) <> BLANK(), LOOKUPVALUE('Org Table'[L3 ID], 'Org Table'[Team Leader], _sel), -- is Manager LOOKUPVALUE('Org Table'[L2 ID], 'Org Table'[Manager], _sel) <> BLANK(), LOOKUPVALUE('Org Table'[L2 ID], 'Org Table'[Manager], _sel), -- is Senion Manager LOOKUPVALUE('Org Table'[L1 ID], 'Org Table'[Senior Manager], _sel) <> BLANK(), LOOKUPVALUE('Org Table'[L1 ID], 'Org Table'[Senior Manager], _sel), BLANK() ) RETURN _LevelIDFinal output:
sevenhills
Super User
3 years agoNot sure what is the output you are looking for ?
Check this sample, if this is what you are looking for ...
Source: PO Table and Org Tables:
Relationships:
Measure:
Requester Level =
var _sel = SELECTEDVALUE('PO Table'[Requester])
var _LevelID = SWITCH( TRUE(),
-- is Engineer?
LOOKUPVALUE('Org Table'[L4 ID], 'Org Table'[Engineer], _sel) <> BLANK(), LOOKUPVALUE('Org Table'[L4 ID], 'Org Table'[Engineer], _sel),
-- is team leader
LOOKUPVALUE('Org Table'[L3 ID], 'Org Table'[Team Leader], _sel) <> BLANK(), LOOKUPVALUE('Org Table'[L3 ID], 'Org Table'[Team Leader], _sel),
-- is Manager
LOOKUPVALUE('Org Table'[L2 ID], 'Org Table'[Manager], _sel) <> BLANK(), LOOKUPVALUE('Org Table'[L2 ID], 'Org Table'[Manager], _sel),
-- is Senion Manager
LOOKUPVALUE('Org Table'[L1 ID], 'Org Table'[Senior Manager], _sel) <> BLANK(), LOOKUPVALUE('Org Table'[L1 ID], 'Org Table'[Senior Manager], _sel),
BLANK()
)
RETURN _LevelID
Final output: