Forum Discussion
Using SelectedValue in measure for computing volume
- 3 months ago
The fix is to move the SELECTEDVALUE inside the measure using a VAR:
Volume = VAR _SelectedDate = SELECTEDVALUE ( 'Complaints Raw Data'[Date Received] ) RETURN CALCULATE ( COUNT ( 'Complaints Raw Data'[short_id] ), 'Complaints Raw Data'[Date Received] = _SelectedDate ) - 3 months ago
Hi,
Create a Calendar table and have a *:1 relationship from the Date received column to the Calendar table. To your slicer, drag the Date from the Calendar table. Write this measure
Volume = count('Complaints Raw Data'[short_id])
Hope this helps.
Hi,
The error occurs because CALCULATE's filter arguments must be Boolean column expressions or table expressions — you cannot directly reference a measure (like [SelectedDate]) inside a filter predicate. DAX doesn't allow Column = Measure as a direct filter argument.
Volume =
CALCULATE(
COUNT('Complaints Raw Data'[short_id]),
FILTER(
'Complaints Raw Data',
'Complaints Raw Data'[Date Received] = [SelectedDate]
)
)
====
FILTER() returns a table, which CALCULATE accepts. Inside FILTER, the row-by-row evaluation resolves the measure correctly.
Hope this gets you moving in the right direction! If it solved your problem, hitting 'Mark as Solution' helps others find the answer faster. Kudos are always appreciated too — they go a long way in keeping this community thriving.
I'm always happy to help. Don't hesitate to reach out if you have more questions!