Forum Discussion
ek2112
8 years agoAdvocate II
Dynamic calculation based on slicer selection
I have two tables, 'Work Details' and 'Rate' and linked by 'Name' column. Each employee has their own hourly rates in the 'Rate' table's 'Rate' column. I have additional columns in the Rate table...
ek2112
8 years agoAdvocate II
v-jiascu-msft after quite a bit of effort, I tweaked the formula a bit and got it working. Thanks for your help.
Just one final question - is there a way to get the actual costs based on different rates for different time periods? E.g. For one resource, if the resource has $30/hr for Jan, cost = [work time] * 30, else cost = [work time] * rate_selected. I tried DATEDIFF but could not quite get it. Thanks.
Daily Emp Cost New = VAR minIndex = CALCULATE ( MIN ( 'Work Details'[Index] ), ALLEXCEPT ( 'Work Details', 'Work Details'[Name], 'Work Details'[Work date] ), 'Work Details'[Employee Type] = "Full-time" ) VAR dailyhours = CALCULATE ( SUM ( 'Work Details'[Work Time] ), ALLEXCEPT ( 'Work Details', 'Work Details'[Name], 'Work Details'[Work date] ) ) VAR rate_selected = IF ( HASONEVALUE ( Rate[Rates] ), LOOKUPVALUE ( Rate[Value], Rate[Name], MIN ( 'Work Details'[Name] ), Rate[Rates], MIN ( Rate[Rates] ) ), LOOKUPVALUE ( Rate[Value], Rate[Name], MIN ( 'Work Details'[Name] ), Rate[Rates], "Rate" ) ) RETURN IF (MIN ( [Employee Type] ) = "Full-time", IF ( MIN ( 'Work Details'[Index] ) = minIndex, IF (SELECTEDVALUE ( 'Work Details'[Weekend] ) = FALSE (), 8* rate_selected, IF(SELECTEDVALUE ( 'Work Details'[Weekend] ) = TRUE(), 0, MIN ([Work Time]) * rate_selected)),IF(MIN ( [Employee Type] ) = "Contractor", MIN ( [Work Time] ) * rate_selected,0)),MIN ( [Work Time] ) * rate_selected)
v-jiascu-msft
8 years agoMicrosoft Employee
Hi ek2112,
So glad you solve it. Maybe you can set another VAR to get the $30/hr then you can apply it in the formula. That will depend on where we can get the $30/hr.
Best Regards,
Dale