Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hi,
I have one specific requirement in Power BI that I am unable to figure out.
I have an 'Employees' table in my data model which consists of the following columns and sample data,
In the 'reportsTo' column, we have employee IDs of the managers, but instead of IDs, I want the names of the managers to show up (in a different column).
In SQL, I can achieve this by using self join to connect the Employees table to itself on the condition reportsTo = employeeNumber.
How can I achieve the same results using Power BI?
Thanks,
Sourav
Solved! Go to Solution.
Hey @Anonymous ,
my table looks like this:
I use this DAX statement to create a calculated column:
reportsto name =
var reportsto_id = 'Table'[reportsto]
return
CALCULATE(
FIRSTNONBLANK('Table'[name] , 0)
, FILTER(
ALL('Table')
, 'Table'[id] = reportsto_id
)
)
Now the table looks like this:
Hopefully this is what you are looking for.
Regards,
Tom
Hey @Anonymous ,
my table looks like this:
I use this DAX statement to create a calculated column:
reportsto name =
var reportsto_id = 'Table'[reportsto]
return
CALCULATE(
FIRSTNONBLANK('Table'[name] , 0)
, FILTER(
ALL('Table')
, 'Table'[id] = reportsto_id
)
)
Now the table looks like this:
Hopefully this is what you are looking for.
Regards,
Tom
Hi Tom,
Thanks for your help, the formula is working 🙂.
I was just wondering why the formula is not working without defining a 'var' and using 'return'. Is it not possible to achieve the same resultset by using only CALCULATE or some other DAX function? Just curious.
Thanks,
Sourav
Hey @Anonymous ,
you have to be aware that creating a calculated column always starts with a Row Context - the current row, using CALCULATE always transforms the values of the current row into a filter context, this step during the evaluation of CALCULATE is called context transition. As soon as context transition happens it's no longer possible to access the values from the outer row context without special consideration. This can be achieved by either using variables that are defined before context transition happens or using the function EARLIER(...).
I'm using variables in this example for the following reasons:
Hopefully this adds to your understanding why I have been using variables.
Regards,
Tom
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 51 | |
| 40 | |
| 37 | |
| 14 | |
| 14 |
| User | Count |
|---|---|
| 85 | |
| 71 | |
| 38 | |
| 29 | |
| 26 |