Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Zubair_Muhammad 

      I am getting a count of 1 for each ID, which is wrong.

      Thnaks
      A

      • Zubair_Muhammad's avatar
        Zubair_Muhammad
        Icon for Community Champion rankCommunity Champion

        Anonymous 

         

        You might also need to replace Table1 with ALL(Table1) or Allselected(Table1),

         

        because in a MEASURE you have filter context

  • 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.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Ashish_Mathur 

      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