Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
Check it out now!Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
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 |
Solved! Go to Solution.
You can change Operator Total Hrs2 to Return _calc now.
Proud to be a Super User! | |
Sure.
Share your formulas for both Operator Name and for Operator Total Hours.
Proud to be a 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.
Proud to be a Super User! | |
Ok, let us change the Operator Total Hours calculated column to this...
Operator Total Hours2 =
var _operatorName =
codeTable[operatorName]
var _workDate =
codeTable[Workdate]
var _calc =
CALCULATE(
SUM(codeTable[laborhrs]),
FILTER(ALL(codeTable), codeTable[operatorName] = _operatorName && codeTable[Workdate] = _workDate)
)
Return
_calc
Proud to be a Super User! | |
Ok, replace the "_calc" with _OperatorName and see if the names are returned.
Then replace _calc with _workdate and see if the workdates are returned.
Let me know how that works
Proud to be a Super User! | |
When I replace _calc with Operatorname then retuen Operatorname.
When I replace _calc with Workdate tehn return Workdate.
But I need total hrs.
Thanks
Rupal
Thanks. That allows me to know that there are no errors in the data.
When you use
Operator Total Hours2 =
var _operatorName =
codeTable[operatorName]
var _workDate =
codeTable[Workdate]
var _calc =
CALCULATE(
SUM(codeTable[laborhrs]),
FILTER(ALL(codeTable), codeTable[operatorName] = _operatorName && codeTable[Workdate] = _workDate)
)
Return
_calc
What data values or errors are returned? Could you grab a screen shot of the results?
Proud to be a Super User! | |
Sorry for late reply. It coming out blank(no data, no error)
Thanks
This is a bit of a head scratcher.
Can you add a test for labour hours into the code as follows and then return _rowHours and let me know. The basic premise is that we added the operator name to each row in the table and now we are doing a simple sum for each operator for each workdate.
Operator Total Hours2 =
var _rowHours =
codeTable[labourhrs]
var _operatorName =
codeTable[operatorName]
var _workDate =
codeTable[Workdate]
var _calc =
CALCULATE(
SUM(codeTable[laborhrs]),
FILTER(ALL(codeTable), codeTable[operatorName] = _operatorName && codeTable[Workdate] = _workDate)
)
Return
_calc
Proud to be a Super User! | |
Well now we are getting somewhere.
Going back to the beginning...
We started with...
If you created a calculated column at this point that was
RowHours = codeTable[labourhrs]
It should just pull the labour hours over for all rows except the equipment rows.
Can you double check that this happens in your data?
Assuming that works correctly, we added the Operator Name to each row.
operatorName =
var _nameLookup =
LOOKUPVALUE(codeTable[name],codeTable[Laborcode],codeTable[Equipmentlaborcode])
Return
IF(
OR(ISBLANK(_nameLookup), _nameLookup=""),
[name],
_nameLookup
)
All this is doing looking in the labourcode column for the Equipmentlabourcode and returning whatever the name is for that row. The Equipmentlabourcode and labourcode need to be in the same format for this to work. If this worked correctly the table that results should look like...
Can you verify that this is the result you get?
Let me know how these work and we will go from there.
Proud to be a Super User! | |
Its not pulling Operator name for employee_name.
I think I see it...
Replace the code as follows (in bold)...
operatorName =
var _nameLookup =
LOOKUPVALUE(codeTable[name],codeTable[Laborcode],codeTable[Equipmentlaborcode])
Return
IF(
OR(_nameLookup=",", _nameLookup=""),
[name],
_nameLookup
)
Proud to be a 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])
)
Proud to be a Super User! | |
Now Operator Name is pulling. What is our next step? please
You can change Operator Total Hrs2 to Return _calc now.
Proud to be a Super User! | |
Perfect!
Thanks lots for your help
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