Forum Discussion
JustDavid
Helper V
1 month agoUnable to create relationship
Hello PowerBI and DAX gurus, My end goal is to create a measure where I want to get the SUM of ([Hourly Rate] x [Number of Hours]) of each employee who works in that LOB in a given month. However, ...
- 1 month ago
Hi JustDavid
try attached pbix.
Salary Paid by LOB = SUMX ( VALUES ( dimLOB[LOB] ), VAR CurrentLOB = dimLOB[LOB] VAR EmployeesInLOB = CALCULATETABLE ( VALUES ( dimEmployee[EmpName] ), LOB[LOB] = CurrentLOB ) VAR LOBResult = SUMX ( EmployeesInLOB, VAR CurrentEmp = dimEmployee[EmpName] -- Split hours: everything except O/T 1.5, and O/T 1.5 separately VAR RegularHours = CALCULATE ( SUM ( Payroll[Hours] ), Payroll[EmpName] = CurrentEmp, Payroll[Hour Types] <> "O/T 1.5" ) VAR OT15Hours = CALCULATE ( SUM ( Payroll[Hours] ), Payroll[EmpName] = CurrentEmp, Payroll[Hour Types] = "O/T 1.5" ) VAR EffectiveHours = RegularHours + ( OT15Hours * 1.5 ) VAR RateThisMonth = CALCULATE ( AVERAGE ( Timesheets[Hourly Rate] ), Timesheets[EmpName] = CurrentEmp ) VAR PayBeforeAllocation = EffectiveHours * RateThisMonth VAR EmpAllocation = CALCULATE ( SUM ( LOB[Allocation] ), LOB[EmpName] = CurrentEmp, LOB[LOB] = CurrentLOB ) RETURN PayBeforeAllocation * EmpAllocation ) RETURN LOBResult )please give kudos or mark it as solution once resolved.
Regards,
praful
LumericVisuals
Resolver I
1 month agoroot-causes it as a missing real Employee dimension (all three tables are fact-shaped, so EmpName isn't unique on either side), walks through building one via Power Query, and flags the same fix likely applies to date.
JustDavid
Helper V
1 month agoLumericVisuals Thanks for the reply.
Am not really following with your reply here.
What is it that I'm suppose to do?
Am I suppose to create a dimension of Unique Employees (i.e. dimEmp)? And if it is, what is the relationship that I should create to?