Forum Discussion
c_slater_1
4 years agoNew Member
Calculate total from different tables
Hi, I am looking for some help in trying to take data from 2 tables and add them together to get a total. I have taken the data in table 1 below and created a matrix to get a total per day bu...
- 4 years ago
Hi,
Please check the below picture and the attached pbix file.
I did not create any relationship between two tables, and the below is for creating a new table.
New table = VAR _newtable = ADDCOLUMNS ( SUMMARIZE ( Table1, Table1[Date], Table1[Person] ), "@Time from task 1", CALCULATE ( SUM ( Table1[Time from task 1] ) ), "@Time from task 2", SUMX ( FILTER ( Table2, Table2[Date] = EARLIER ( Table1[Date] ) && Table2[Person] = EARLIER ( Table1[Person] ) ), Table2[Time from task 2] ) ) VAR _addtotal = ADDCOLUMNS ( _newtable, "@Total time for all tasks", [@Time from task 1] + [@Time from task 2] ) RETURN _addtotal
Jihwan_Kim
Super User
4 years agoHi,
Please check the below picture and the attached pbix file.
I did not create any relationship between two tables, and the below is for creating a new table.
New table =
VAR _newtable =
ADDCOLUMNS (
SUMMARIZE ( Table1, Table1[Date], Table1[Person] ),
"@Time from task 1", CALCULATE ( SUM ( Table1[Time from task 1] ) ),
"@Time from task 2",
SUMX (
FILTER (
Table2,
Table2[Date] = EARLIER ( Table1[Date] )
&& Table2[Person] = EARLIER ( Table1[Person] )
),
Table2[Time from task 2]
)
)
VAR _addtotal =
ADDCOLUMNS (
_newtable,
"@Total time for all tasks", [@Time from task 1] + [@Time from task 2]
)
RETURN
_addtotal- c_slater_14 years agoNew Member
Thank you for this, I have implemented against my master data sets and has worked exactly as I wanted.
Really appreciate the help