Absolutely clear - thanks for systematic explanations!
I am a firm believer in virtual tables myself since VAR was first released. But I always say, " we learn something new everyday!". Your explanation on point 2 nailed. It makes absolutely sense & made it work (thus saving me the resource intense approach of materializing the virtual tables)
I did a bit of online research and you are spot on with your use of AVERAGEX - the general āagreementā is that one can access columns within virtual tables using only the X family of DAX functions. Aggregators wonāt work!
Only question I may have is if you had a chance to look at what I am aiming to achieve overall with this post?
@mickeydjw is already helping me out as I also try to figure out a solution (of course with thanks to your help on the virtual table) as well. Donāt know if you maybe have insights as well?
I learned this lesson the hard way. I had a number of attempted solutions in the past where Iād build a complex virtual table and then have no way to call the column I needed, since you need the function youāre using to have an explicit table call to access the virtual table. X functions all work well, as do TOPN, COUNTROWS, etc. - anywhere you can āactivateā the virtual table directly.
Iāve been reading this thread, but havenāt dived into the details, since I didnāt want to step on @mickeydjwās work on the solution or duplicate efforts. Just noticed the DAX virtual table problems and figured Iād send that along. But if you and @mickeydjw would like another set of eyes on the problem, Iād be happy to do that.
Iād very appreciate any set of eyes on this āspecialā case I have on me
Iāve been stuck on this for quite a while and hoping help will come from EDNA. @mickeydjw has taken particular interest but please feel free to jump in. So far Iāve gotten as far the virtual table for each pathitemreverse level to get team score. Just trying anything here.
And like you, Iām learning the hard way with this report challenge
Sure ā glad to pitch in and see if I can help crack this one. Two things that would be a huge help - can you please post your most recent PBIX file incorporating the progress youāve made to date, and provide a mockup of the final result youād like to see.
Each managerās team score takes as input the total score from their employee. The total score is a weighted average of an individual & team score for each employee (including managers!). for employees with no teams (Team L0 in the employee table of pbix), easy: individual is same as total score. It getās trick once from Team L1 through L3. Two challenges:
How do I calculate Emp Bās Team score with Total score from Emps C (this one is easy as Emp C is Team L0) & D with Emp Dās Team score that feeds into its Total score relying on the Total score of Emps F & G
Notice Emp B spans Team L1 & Team L2. How do I ensure Team score calculations only focuses on direct reports (in this case Emps C & D)? In case Team L1 would be relevant for Emp B
I hope this clarifies the work @mickeydjw & I are both looking at. Otherwise do let me know. I have also attached the excel prototype for the formulas on calculating the team & total scores
Thanks very much for the detailed explanation and all the associated files. Iām starting to dig into this one in-depth - itās a really interesting problem. @Melissa and I are also tag teaming on a complex support request for @benwann1, and Iāve got a number of pressing work deadlines this week, so I may not be as prompt as usual in getting back with a solution on this, but will keep you posted on my progress.
Thanks for having a look. No worries re response timing. Indeed, it is a challenge that has got me stumped. Iāve not progressed beyond the updated pbix file I sent you (each time I think I made a progress I go back to square one!)
Due to the length by which this post has been active, we are tagging it as Solved. For further questions related to this post, please make a new thread. You may check this how-to guide for reference - How To Use The Enterprise DNA Support Forum
Incredibly fun and challenging problem. Making progress, but have a question - can I always count on the maximum number of levels being 4, or do I need to account for that being dynamic as well?
number of levels to account for dynamism. Some managers will be only 3, while some may go up to 7!
One thing I noticed when I worked on it, also, is that a manager could have employees with mixed levelsā¦for example a manager could have an employee with no management role reporting to him/her AND as well another employee with management role. In the prototype excel mockup, as a practical example, we could have a scenario where Person 2 reports to LM 3 instead of reporting to LM 1
OK, 7 is the number I needed (frankly, I was hoping it would be 4, but you have to play the cards youāre dealt, not the cards you wantā¦). If you have Russo and Ferrariās āDAX Patternsā, the last chapter on Parent-Child Hierarchies is very useful, and in it they state āto create the right number of calculated columns, you must know in advance the maximum depth of the hierarchy. Otherwise you have to estimate it because the number cannot change dynamicallyā.
I spent last night sketching this problem out and rubber ducking potential approaches, which convinced me of two things:
we are going to have to eat this elephant in small pieces. As youāve identified, the self scoring portion is easy. However, jumping from that straight to the full team calculation is too big and complex a piece to digest. The approach I plan to take is to start with a two level hierarchy (A,B and H), predicated on a reshaped supporting table that defines the direct reporting relationships:
This type of supporting table should make writing the DAX much easier. Then once weāve validated that weāve got a two level hierarchy working, we keep building out until we get to level 7.
currently, we have DAX doing too much of the work. Given the static nature of the hierarchical relationships, a lot of this task I think can and will be handled ultimately via Power Query. In order to start doing that, can you please upload the ā20190817 Sample data.xlsxā file?
While so far Iāve been working primarily at just a conceptual level, I did mark the date table, and change the DAX in the Team L0 calculated column to:
Rather than waiting until I have a full 7ālevel solution, I will post progress as I go so that you, @mickeydjw and I can work together in moving this one forward.
Indeed this is an interesting approach you bring up. Iām all excited. Yes I do have the DAX Patterns and will review that portion. What intrigues me is the use of Power Query as youāve mentioned: I doubt I ever come across hierarchies built in PQ (Iām usually one to go as far as possible in PQ before handing over to DAX for modelling).
Thanks very much for promptly posting the data file. In rereading my previous message, I can see that it was unclear. Your employee table and the created hierarchies are perfect - exactly the form that Russo and Ferrari recommend.What I was referring to was the supporting tables that I think we will need to create in order to iterate over to develop the team scores. Because these hierarchies will be static (in terms of not changing during a single session), we can materialize these as physical tables using Power Query, rather than as virtual table variables in DAX measures. This will definitely make our measures less complex and the overall analysis easier to debug.
I havenāt worked much with PATH functions in the past, so this will be a good learning experience for both of us in different ways.
More to follow soonā¦
Brian
P.S. I came across this video at lunch today. Iāve never seen this done in Power Query either, but some interesting techniques here:
Hi @Bare, weāve noticed that no response has been received from you since the 5th of March. We just want to check if you still need further help with this post? In case there wonāt be any activity on it in the next few days, weāll be tagging this post as Solved. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the checkbox. Thanks!