Forum Discussion
clubspec
Helper III
3 years agoTricky SUM with two tables
Hi Gurus, I have two tables like in the picture. There is a relationship between 'Calendar'[Date] and 'Asset Register'[Start Date]. Now I want to do a sum for [Monthly Depreciation] from the Asset...
- 3 years ago
Hi clubspec
You can use the CROSSFILTER function to remove the relationship just for this measure.
Something like this:
Monthly Dep = VAR _MaxDate = MAX('Date'[Date]) VAR _Result = CALCULATE( SUM('Asset Register'[Monthly depreciation]), CROSSFILTER('Date'[Date], 'Asset Register'[Start Date], None), 'Asset Register'[Start Date] <= _MaxDate, 'Asset Register'[End Date] >= _MaxDate ) RETURN _Result
PaulOlding
Solution Sage
3 years agoHi clubspec
You can use the CROSSFILTER function to remove the relationship just for this measure.
Something like this:
Monthly Dep =
VAR _MaxDate = MAX('Date'[Date])
VAR _Result =
CALCULATE(
SUM('Asset Register'[Monthly depreciation]),
CROSSFILTER('Date'[Date], 'Asset Register'[Start Date], None),
'Asset Register'[Start Date] <= _MaxDate,
'Asset Register'[End Date] >= _MaxDate
)
RETURN
_Result