Forum Discussion
Yenn
3 years agoFrequent Visitor
Calculate the different hours between two tables
Hi @everyone, I am trying to calculate the different hours between two tables but it's not working, what should I do in this case? Table 2: Table 1: When I typed the formula b...
AmiraBedh
3 years agoSuper User
Are you considering the ID in your calculation ?
Logically, I can calculate the diffrence in hours between the two tables for the same ID.
In that case you need to join the two tables on the IDs so that you can perform calculations on the corresponding rows.You can then calculate the difference in hours between the two tables for the corresponding IDs.
Create Relationships Between Tablesi f you haven't already, you might want to create a relationship between the tables using the common ID field.
and then :
Difference_in_Hours =
SUMX(
Table1, // Assuming you want to iterate through Table1
VAR RelatedRow = RELATEDTABLE(Table2) // Fetch related row from Table2
VAR Hours1 = Table1[hours] // Get hours from Table1
VAR Hours2 = SUMX(RelatedRow, Table2[hours]) // Get hours from related row in Table2
RETURN Hours1 - Hours2 // Return the difference
)