Forum Discussion
Count if Date is earlier than selected date
Hi,
I am trying to count the distinct number of CarerRef if the StartDate is before a selected date in a slicer (this slicer gets its date from DateKey table). Only count CarerRef if DateLeft is blank.
Using: Active Point In Time = CALCULATE(DISTINCTCOUNT(vw_CrystalCarerAudit[CarerRef]),vw_CrystalCarerAudit[DateLeft] <> BLANK(),vw_CrystalCarerAudit[StartDate] <= RELATEDTABLE(DateKey),DateKey[Date])
but getting scalar value error: The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
What am I doing wrong here?
Hi,
Give this a shotActive Point In Time = VAR selecteddate = SELECTEDVALUE ( DateKey[Date] ) RETURN CALCULATE ( DISTINCTCOUNT ( vw_CrystalCarerAudit[CarerRef] ), vw_CrystalCarerAudit[DateLeft] <> BLANK (), vw_CrystalCarerAudit[StartDate] <= selecteddate )
7 Replies
- liuRegular Visitor
Try:
Active Point In Time = CALCULATE(
DISTINCTCOUNT(vw_CrystalCarerAudit[CarerRef]),
FILTER(vw_CrystalCarerAudit[DateLeft] <> BLANK(),
vw_CrystalCarerAudit[StartDate] <= RELATEDTABLE(DateKey),DateKey[Date]))
- android1
Post Patron
Doesn't like the 2 filters. It's giving me 'Too many arguments were passed to the FILTER function. The maximum argument count for the function is 2.'
- liuRegular Visitor
Try this instead:
Active Point In Time = CALCULATE
(
DISTINCTCOUNT(vw_CrystalCarerAudit[CarerRef]),
FILTER(vw_CrystalCarerAudit,
vw_CrystalCarerAudit[DateLeft] <> BLANK() &&
vw_CrystalCarerAudit[StartDate] <= RELATEDTABLE(DateKey),DateKey[Date])
)