Forum Discussion

hidzirf's avatar
hidzirf
Helper I
4 years ago
Solved

Count row with filter condition

Hello Experts,

 

I need help. I have a set of data that consist of 12-month data. I already created a measure 

AllCount = COUNT(Table[Colum]). Now I would like to create another measure to count the row but only for the last 1 month. How can I do that?
 
Thank you.
  • hidzirf Please try this:-

     

    Measure = CALCULATE(DISTINCTCOUNT('Table (2)'[Number]),FILTER('Table (2)',MONTH('Table (2)'[Date]) = MONTH( TODAY())-1))

     

4 Replies

  • Samarth_18's avatar
    Samarth_18
    Community Champion

    Hi hidzirf ,

     

    You can create a measure like below:-

    measure = countrows(filter(table,table[date] = today()-30))

     

    Thanks,

    Samarth

    • hidzirf's avatar
      hidzirf
      Helper I

      Hi Samarth,

       

      Thank you for your reply. I have tried the measure that you have shared but the result is not correct - showing as blank.

      I'm giving you another example as below table.

       

      Number

      Question Type

      Result

      Date

      PART123

      Why

      3

      28/2/2022

      PART123

      How

      3

      28/2/2022

      PART123

      Where

      4

      28/2/2022

      PART123

      What

      4

      28/2/2022

      PART456

      Why

      2

      15/2/2022

      PART456

      How

      3

      15/2/2022

      PART456

      Where

      3

      15/2/2022

      PART456

      What

      4

      15/2/2022

      PART789

      Why

      5

      10/1/2022

      PART789

      How

      4

      10/1/2022

      PART789

      Where

      3

      10/1/2022

      PART789

      What

      2

      10/1/2022

      PART000

      Why

      5

      1/1/2022

      PART000

      How

      3

      1/1/2022

      PART000

      Where

      2

      1/1/2022

      PART000

      What

      2

      1/1/2022

       

      I would like to create a measure to show the number of participants on a card. So each participant needs to answer 4 types of questions. So I created a measure DISTINCTCOUNT(Table[Number]) to have the total numbers of participants which is 4. And now I have to create another measure to show how many participants for last month (February) which is should be 2.

      Please let me know if you have any other suggestions.Thank you.

       

      Regards,

      • Samarth_18's avatar
        Samarth_18
        Community Champion

        hidzirf Please try this:-

         

        Measure = CALCULATE(DISTINCTCOUNT('Table (2)'[Number]),FILTER('Table (2)',MONTH('Table (2)'[Date]) = MONTH( TODAY())-1))