Forum Discussion
Measure with countrows and earlier filter
Hey All,
I have a calculated column which I want to migrate to a measure.
I want to use this measure in a few different visuals and apply different filters on those visuals.
Mumber of Reviews Per Year =
CALCULATE (
COUNTROWS ( Table1 ),
FILTER (
Table1,
Table1[id]
= EARLIER ( Table1[id] )
),
FILTER (
Table1,
Table1[REVIEW_DATE].[Year]
= EARLIER ( Table1[REVIEW_DATE].[Year] )
)
)How can I do it?
The Measure does not like the earlier function.
Thanks!
A
9 Replies
- Zubair_Muhammad
Community Champion
Anonymous
Try replacing EARLIER with SELECTEDVALUE
- AnonymousNot applicable
- Zubair_Muhammad
Community Champion
Anonymous
You might also need to replace Table1 with ALL(Table1) or Allselected(Table1),
because in a MEASURE you have filter context
- Ashish_Mathur
Super User
Hi,
Ensure you have a Calendar Table with a Year column. Build a relationship from the Review Date column of Table1 to the Date column of the Calendar Table. To your visual, drag Year from the Calendar Table and id from Table1. Write this measure
Mumber of Reviews Per Year = COUNTROWS(Table1)
Hope this helps.
- AnonymousNot applicable
Thanks for your reply.
I followed your steps but it does not give the required result.
1. The year column is empty, not sure why.
2. The count gives 1 for each record.
M = COUNTROWS('Table1')Thanks!
A- Ashish_Mathur
Super User
It should work. I'll need to see your file.