Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ShaneHi
Frequent Visitor

Power BI - Lookup within existing table to add new columns for missing manager information

Hi,

 

I'm looking for some support in creating additional column(s) which lookup within the same table.

 

I've attached a similar table below where my data currently runs from Columns A - D. I would like Columns E-H to be created looking up the data from the existing table.

 

Is this achievable  and how would I do it?

 

ABCDEFGH
UserIDUserNameManagerIDManagerName(new column) Manager2ID(new column) Manager2Name(new column) Manager2ID(new column) Manager2Name
1Homer Simpson5Carl Carlson2Waylon Smithers3Montogomery Burns
2Waylon Smithers3Montogomery Burns6Canary Montogomery Burns  
3Montogomery Burns6Canary Montogomery Burns    
4Lenny Leonard2Waylon Smithers3Montogomery Burns6Canary Montogomery Burns
5Carl Carlson2Waylon Smithers3Montogomery Burns6Canary Montogomery Burns
6Canary Montogomery Burns      
7Mindy Simmons2Waylon Smithers3Montogomery Burns6Canary Montogomery Burns
2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

@ShaneHi 

ManagerID2 = 
    VAR __ManagerID = [ManagerID]
    VAR __Result = MAXX( FILTER('Table', [UserID] = __ManagerID), [ManagerID] )
RETURN
    __Result

ManagerID2 Name = 
    VAR __ManagerID = [ManagerID]
    VAR __Result = MAXX( FILTER('Table', [UserID] = __ManagerID), [ManagerName] )
RETURN
    __Result

ManagerID3 = 
    VAR __ManagerID = [ManagerID2]
    VAR __Result = MAXX( FILTER('Table', [UserID] = __ManagerID), [ManagerID] )
RETURN
    __Result

ManagerID3 Name = 
    VAR __ManagerID = [ManagerID2]
    VAR __Result = MAXX( FILTER('Table', [UserID] = __ManagerID), [ManagerName] )
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Anonymous
Not applicable

Hi @ShaneHi 

 

@Greg_Deckler Thank you very much for your prompt reply. Please allow me to follow up on this post.

 

For your question, here is the method I provided:

 

(new column) Operation Manager ID = 
var _ManagerName = [ManagerName]
var _result = MAXX(FILTER('Table', [UserName] = _ManagerName), [ManagerID])
var _UserID = MAXX(FILTER('Table', [Job Role] = "Operation Manager"), [UserID])
RETURN IF( _result = _UserID || [ManagerID] = _UserID, _UserID, BLANK())

 

(new column) Operation Manager Name = 
var _OperationManagerID = [(new column) Operation Manager ID]
var _Result = MAXX(FILTER('Table', _OperationManagerID = [UserID]), [UserName])
RETURN _Result

 

Here is the result.

 

vnuocmsft_0-1712731695030.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@ShaneHi 

ManagerID2 = 
    VAR __ManagerID = [ManagerID]
    VAR __Result = MAXX( FILTER('Table', [UserID] = __ManagerID), [ManagerID] )
RETURN
    __Result

ManagerID2 Name = 
    VAR __ManagerID = [ManagerID]
    VAR __Result = MAXX( FILTER('Table', [UserID] = __ManagerID), [ManagerName] )
RETURN
    __Result

ManagerID3 = 
    VAR __ManagerID = [ManagerID2]
    VAR __Result = MAXX( FILTER('Table', [UserID] = __ManagerID), [ManagerID] )
RETURN
    __Result

ManagerID3 Name = 
    VAR __ManagerID = [ManagerID2]
    VAR __Result = MAXX( FILTER('Table', [UserID] = __ManagerID), [ManagerName] )
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks so much for this Greg - that works perfectly as I asked.

 

I'm going to be cheeky with a follow up ask if thats okay?

 

Would it be possible for me to add a further filter/query to the code?

 

In the table I've added a new column for "Job Role", and i've changed columns F&G to relate specifically to pulling the Operation Manager name.

 

Is that possible?

 

AB CDEFG
UserIDUserNameJob RoleManagerIDManagerName(new column) Operation Manager ID(new column) Operation Manager Name
1Homer SimpsonAdvisor5Carl Carlson2Waylon Smithers
2Waylon SmithersOperation Manager3Montogomery Burns  
3Montogomery BurnsManager6Canary Montogomery Burns  
4Lenny LeonardSenior Advisor2Waylon Smithers2Waylon Smithers
5Carl CarlsonSenior Advisor2Waylon Smithers2Waylon Smithers
6Canary Montogomery BurnsOwner    
7Mindy SimmonsAdvisor2Waylon Smithers2Waylon Smithers
Anonymous
Not applicable

Hi @ShaneHi 

 

@Greg_Deckler Thank you very much for your prompt reply. Please allow me to follow up on this post.

 

For your question, here is the method I provided:

 

(new column) Operation Manager ID = 
var _ManagerName = [ManagerName]
var _result = MAXX(FILTER('Table', [UserName] = _ManagerName), [ManagerID])
var _UserID = MAXX(FILTER('Table', [Job Role] = "Operation Manager"), [UserID])
RETURN IF( _result = _UserID || [ManagerID] = _UserID, _UserID, BLANK())

 

(new column) Operation Manager Name = 
var _OperationManagerID = [(new column) Operation Manager ID]
var _Result = MAXX(FILTER('Table', _OperationManagerID = [UserID]), [UserName])
RETURN _Result

 

Here is the result.

 

vnuocmsft_0-1712731695030.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.