Forum Discussion
SEunson
4 years agoFrequent Visitor
Conditional Sum - Two Unrelated Tables
Hello,
I have two unrelated tables. In Table A I have a date column and I could like to add a calculated colum which sums up Work Hours in Table B, depending on a condition.
For each row in Table A, I would like to compare the date in Table A and check if it is between two dates in Table B. I would like this to iterate through all the rows in Table B and only sum up the hours where this condition is true.
I tried this, but it doesn't seem to work:
Hours =
SUMX(
FILTER(
'Table B',
TableA[Date] > TableB[Start Date] && TableA[Date] < TableB[Finish Date]
),
TableB[Work Hours]
)
Any suggestions or help would be much appreciated.
Thanks!
Hi SEunson
you may try
Hours = VAR CurrentDate = TableA[Date] RETURN SUMX ( 'Table B', IF ( TableB[Start Date] < CurrentDate && TableB[Finish Date] > CurrentDate, TableB[Work Hours] ) )