cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Honne2021
Frequent Visitor

Index Match through DAX or Power Query

Hi, 

I have tried doing this in excel but I need to use an array formula which eats up so much of my memory and my laptop eventually cant manage it. 😞 I hope anyone can assist me on this. 

1st file I have is like this:

Employee Name:Organizational Hierarchy:
(Employee ID  10020): Jeon Jungkook

(Employee ID 10001): Kim Namjoon

(Employee ID 10002): Kim Seokjin
(Employee ID 10010): Min Yoongi
(Employee ID  10020): Jeon Jungkook


My look up file looks like this:

 

ManagerTeam Name
Kim NamjoonTeam A
Kim SeokjinTeam B
Min YoongiTeam B.1


The result I should get is:

Employee Name:Organizational Hierarchy:Result is Main TeamResult is Sub Team
(Employee ID  10020): Jeon Jungkook

(Employee ID 10001): Kim Namjoon

(Employee ID 10002): Kim Seokjin
(Employee ID 10010): Min Yoongi
(Employee ID  10020): Jeon Jungkook

Team BTeam B.1

 

It's difficult because the entire org chart is in 1 cell and I just need to get 1st is their Main Team (in this example is Team B) and their sub group (in this example is Team B.1). The look up list is very long but that is basically the gist of it. 

A powerquery solution or dax formula would be very helpful. Thank you!

1 ACCEPTED SOLUTION
Eyelyn9
Community Support
Community Support

Hi @Honne2021 ,

 

Add a Level column first:

Level = IF(CONTAINSSTRING([Team Name],"."),2,1)

Eyelyn9_0-1638347238586.png

Then try:

 

Result is Main Team = 
 var _table= FILTER(ADDCOLUMNS(CROSSJOIN('Table1','Table2'),"a",CONTAINSSTRING([Organizational Hierarchy:],[Manager])),[a]=TRUE())
 return MAXX(FILTER(_table,[Organizational Hierarchy:]=EARLIER('Table1'[Organizational Hierarchy:]) && [Level]=1 && [Team Name]<>"Team A"),[Team Name])

Result is Sub Team = 
 var _table= FILTER(ADDCOLUMNS(CROSSJOIN('Table1','Table2'),"a",CONTAINSSTRING([Organizational Hierarchy:],[Manager])),[a]=TRUE())
 return MAXX(FILTER(_table,[Organizational Hierarchy:]=EARLIER('Table1'[Organizational Hierarchy:]) && [Level]=2 && [Team Name]<>"Team A"),[Team Name])

Eyelyn9_1-1638347307665.png

 

 

Best Regards,
Eyelyn Qin
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

4 REPLIES 4
Eyelyn9
Community Support
Community Support

Hi @Honne2021 ,

 

Add a Level column first:

Level = IF(CONTAINSSTRING([Team Name],"."),2,1)

Eyelyn9_0-1638347238586.png

Then try:

 

Result is Main Team = 
 var _table= FILTER(ADDCOLUMNS(CROSSJOIN('Table1','Table2'),"a",CONTAINSSTRING([Organizational Hierarchy:],[Manager])),[a]=TRUE())
 return MAXX(FILTER(_table,[Organizational Hierarchy:]=EARLIER('Table1'[Organizational Hierarchy:]) && [Level]=1 && [Team Name]<>"Team A"),[Team Name])

Result is Sub Team = 
 var _table= FILTER(ADDCOLUMNS(CROSSJOIN('Table1','Table2'),"a",CONTAINSSTRING([Organizational Hierarchy:],[Manager])),[a]=TRUE())
 return MAXX(FILTER(_table,[Organizational Hierarchy:]=EARLIER('Table1'[Organizational Hierarchy:]) && [Level]=2 && [Team Name]<>"Team A"),[Team Name])

Eyelyn9_1-1638347307665.png

 

 

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

Thank you for looking into this! 

AlexisOlson
Super User
Super User

I'd strongly recommend splitting the hierarchy into multiple rows before trying to work with it further.

 

Why is the result Team B rather than Team A? You only want to consider the two levels above?

Thank you for looking into this. The result is Team B because Team A is assumed to be the leadership team's group, the c-level employees like the CFO, CEO and the likes..I only need to get the employee's main team and their sub team. I did not break up the org hierarchy and just used the Lookupvalue formula in dax but it did not work. 

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

Power BI Dev Camp Session 22 with aka link 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!