Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Error in measures between two linked tables

Hello. I have two tables. Table_1 is for scheduled work that contains an employee ID, work area number, cost center number, the date, and the amount of scheduled hours (along with others that are irrelevant to this question). Table_2 is time punch info and contains employee ID, cost center number, the date, and the amount of hours worked. Note that workcenters are unique, but cost centers are not (workcenters are beneath cost centers). I have also created a unique ID (called Identifier) in both tables that concatenates the cost center number,the date, and the employee ID because employees can potentially punch twice in two different cost centers on a given day. 

 

I am attempting to build a productivity report from this data, but the measure to compute total hours worked is not filtered correctly, and is returning the wrong value. Here is what I am doing:

 

mProductivity = CALCULATE(
DIVIDE(
SUM( Table_2[Scheduled Hours] ) ,
SUM(Table_2[Total Work Hours]),0
),
USERELATIONSHIP(Table_2[Identifier],Table_1[Identifier]))
 
I have separate dimension tables for employee IDs, a date table, and cost centers.
 
Both tables are linked to every dimension table. I cannot figure out why this is not working and would appreicate any sort of advice!
 
Cheers
4 REPLIES 4
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

I make a test as below, could you have a try like me?

4.png5.png

Measure = SUM('1'[hour planned])

Measure 2 = SUM('2'[hour worked])

Measure 3 = [Measure]/[Measure 2]

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

@v-juanli-msft  Thanks for the response. The measures that you have provided work, but when I attempt to filter both measures by cost center, then that is when I get an error. My question then becomes how I can create a link between each cost center such that filtering works on both measures.

Hi @Anonymous 

I can't reproduce your problem.

Could you provide a simple test file, then upload to one drive  and share me the link?

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

I have also created two other measures to separate the hours worked and the hours scheduled:

 

mTotalStd= CALCULATE(
SUM(
Table_1[Scheduled Hours]
),
USERELATIONSHIP(
Table_1[Identifier],Table_2[Identifier]
)
)
 
 
mTotalWorked= CALCULATE(
SUM(
Table_2[Total Work Hours]
),
USERELATIONSHIP(
Table_1[Identifier],Table_2[Identifier]
)
)
 
 I created a table shown in the top screenshot, but the total worked hours measure is off. The screenshot on the bottom is correct and the screenshot on the top is incorrect. The bottom is using summarize whereas top table is using the calculated measures.
hourstable.PNGCapture.PNG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.