Forum Discussion
Running total with inactive relationship
jon_w , Try with these two measures
Measure 1= CALCULATE('_Measures'[Contact: Active Count],
USERELATIONSHIP('Contact Acquired'[Acquisition Date], 'Date Dimension'[Calendar Date]))
zTest - Running Total 2 =
CALCULATE(
[Measure 1],
FILTER(
ALL('Date Dimension'),
'Date Dimension'[Calendar Date] <= MAX('Date Dimension'[Calendar Date])
&& 'Date Dimension'[Calendar Date] <= MAX('Contact Acquired'[Acquisition Date])
)
)
amitchandak thank you for the prompt response - but that still returns dates beyond the max acquisition date:
- Anonymous2 years agoNot applicable
That's how cumulative totals work, as they are a sum of all the previous months, every month will have a cumulative value as long as one before it had one. If you want to remedy this you could do it in the measure like this:
IF(ISBLANK('_Measures'[Contact: Active Count]), BLANK(), /*The rest of that cumulative total measure*/)this isn't ideal because it will also return blanks within the date range where you may not want it to be blank. I'd suggest adding a column to your Date Dimension table:
Past/Present = IF('Date Dimension'[Calendar Date] <= NOW(), 1, 0)
You can then apply this filter to either the visual or within your measure and you will only see the total for dates that have happened. Hope this helps, let me know if you have any issues or further questions.
- jon_w2 years agoRegular Visitor
thanks Anonymous but when I've set this up before use a date table with an already active relationship I didn't have this issue e.g.
Count of Contact (Current Period) running total in Acquistion Date =CALCULATE([Count of Contact (Current Period)],FILTER(ALLSELECTED('Acquisition Date'[Acquistion Date]),ISONORAFTER('Acquisition Date'[Acquistion Date], MAX('Acquisition Date'[Acquistion Date]), DESC)))
Give a running count up to the last date and then stops:- Anonymous2 years agoNot applicable
Yeah that would make sense, effectively you can use inactive relationships in a measure and that specific measure will use the specified inactive relationship. However, the table with your date field is not using it, so it will display all of the values that it has in it's date column as there is no actual filter context outside of the measure where the relationship is specified. I don't think adding a past/present column would be a problem but if you'd rather not I'd probably need to see the whole data model to try and streamline it a bit so that the relationship can be active and you can get the behavior you're after without the need for a past/present column.