Forum Discussion
Look up laborcode in another row in same table in Dax
Hi,
I have laborcode(employee no), name and laborhrs in one row
And euipment, equipmenthrs , equilaborcode in different row.
Laborcode and equilaborcode is same. I would like to identify operator by name.
I did create column
| Workdate | Laborcode | name | laborhrs | equipment | Equipment hrs | Equipmentlaborcode | vendequipmentunit | Operator_name | Oprator total hrs |
| 12/1/2022 | 30017091 | Landry | 0.5 | ||||||
| 12/1/2022 | 30004386 | LETENDRE | 3 | ||||||
| 12/1/2022 | 30012147 | Penkov | 0.5 | ||||||
| 12/1/2022 | 30004376 | ROY | 2.5 | ||||||
| 12/1/2022 | 30004393 | Vergunov | 3 | ||||||
| 12/1/2022 | 30004376 | ROY | 5.5 | ||||||
| 12/1/2022 | 30004393 | Vergunov | 5 | ||||||
| 12/1/2022 | 30004393 | Vergunov | 2 | ||||||
| 12/1/2022 | 160 TON | 4.5 | 30004393 | 160-1-4433 | Vergunov | 10 | |||
| 12/1/2022 | 160 TON | 7 | 30004376 | 160-1-4433 | ROY | 12.5 | |||
| 12/1/2022 | 30004376 | ROY | 2 | ||||||
| 12/1/2022 | 30004376 | ROY | 2.5 | ||||||
| 12/1/2022 | 30017091 | Landry | 2 | ||||||
| 12/1/2022 | 30017091 | Landry | 1 | ||||||
| 12/2/2022 | 30004370 | BANARES | 0.5 | ||||||
| 12/2/2022 | 30017091 | Landry | 0.5 | ||||||
| 12/2/2022 | 30004370 | BANARES | 1 | ||||||
| 12/2/2022 | 100 TON | 2 | 30004370 | 100-1-4617 | BANARES | 10 | |||
| 12/2/2022 | 30004370 | BANARES | 7.5 | ||||||
| 12/2/2022 | 30004370 | BANARES | 1 | ||||||
| 12/2/2022 | 100 TON | 6 | 30017091 | 100-1-4475 | Landry | 11 | |||
| 12/2/2022 | 30017091 | Landry | 7.5 | ||||||
| 12/2/2022 | 30017091 | Landry | 2 | ||||||
| 12/2/2022 | 30017091 | Landry | 1 |
You can change Operator Total Hrs2 to Return _calc now.
20 Replies
- jgeddes
Super User
You can add the following calculated columns...
operatorName =
var _nameLookup =
LOOKUPVALUE(codeTable[name],codeTable[Laborcode],codeTable[Equipmentlaborcode])
Return
IF(
OR(ISBLANK(_nameLookup), _nameLookup=""),
[name],
_nameLookup
)and
Operator Total Hours =
CALCULATE(
SUM(codeTable[laborhrs]),
ALLEXCEPT(codeTable, codeTable[operatorName], codeTable[Workdate])
)- ABC11
Resolver I
Thanks lot to Solution Sage,
Operator name is working fine but Operator Total hours coming blank. Would you help me to figure out.
Thanks again
- ABC11
Resolver I
Now Operator Name is pulling. What is our next step? please
- jgeddes
Super User
You can change Operator Total Hrs2 to Return _calc now.
- jgeddes
Super User
Sure.
Share your formulas for both Operator Name and for Operator Total Hours.- ABC11
Resolver I
Only this is not working.Operator Total HRs =CALCULATE(sum('LEM FACT with query'[LABORHRS]),ALLEXCEPT('LEM FACT with query','LEM FACT with query'[EMPLOYEE_NAME],'LEM FACT with query'[WORKDATE]))Operator Name formula is workingThanks- jgeddes
Super User
I just needed to see what you named the Operator Name column.
The name column that is referenced in the ALLEXCEPT statement needs to be the "Operator Name" column, not the original Employee Name column.