Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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?
Solved! Go to Solution.
Hi,
Give this a shot
Active Point In Time = VAR selecteddate = SELECTEDVALUE ( DateKey[Date] ) RETURN CALCULATE ( DISTINCTCOUNT ( vw_CrystalCarerAudit[CarerRef] ), vw_CrystalCarerAudit[DateLeft] <> BLANK (), vw_CrystalCarerAudit[StartDate] <= selecteddate )
Try:
Active Point In Time = CALCULATE(
DISTINCTCOUNT(vw_CrystalCarerAudit[CarerRef]),
FILTER(vw_CrystalCarerAudit[DateLeft] <> BLANK(),
vw_CrystalCarerAudit[StartDate] <= RELATEDTABLE(DateKey),DateKey[Date]))
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.'
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])
)
Still not liking that ->
Hmm... I've yet to have to use RELATEDTABLE in a FILTER argument, but it seemed like because of the comma, it's assuming DateKey[Date] is a 3rd argument of FILTER, and not just part of RELATEDTABLE.
Perhaps try:
1. Put parenthesis around RELATEDTABLE(DateKey),DateKey[Date]
or
2. Drop the RELATEDTABLE(DateKey), and just use DateKey[Date].
Hi,
Give this a shot
Active Point In Time = VAR selecteddate = SELECTEDVALUE ( DateKey[Date] ) RETURN CALCULATE ( DISTINCTCOUNT ( vw_CrystalCarerAudit[CarerRef] ), vw_CrystalCarerAudit[DateLeft] <> BLANK (), vw_CrystalCarerAudit[StartDate] <= selecteddate )
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
96 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
88 | |
63 |