Forum Discussion

RhoFox's avatar
RhoFox
Frequent Visitor
5 years ago
Solved

Count row with same values in two columns

Hi There

I need help with some column "count"

 

ProjectDateTextCount

P1

01.01.2021text11
P101.01.2021text22
P101.01.2021text33
P102.01.2021text41
P201.01.2021text51
P201.01.2021text62
P102.01.2021text72
P102.01.2021text83
P102.01.2021text94


I need to count number of rows when: Project is the same and Date is the same
i know it's not difficult, but unfortunately i can't find the right formula 😕

 

I am very grateful for every answer

  • Hi, RhoFox 

    Please check the below for creating a new column.

     

     

    Count CC =
    VAR currentproject = 'Table'[Project]
    VAR currentdate = 'Table'[Date]
    RETURN
    RANKX (
    FILTER (
    'Table',
    'Table'[Project] = currentproject
    && 'Table'[Date] = currentdate
    ),
    'Table'[Text],
    ,
    ASC
    )

     

     

5 Replies

  • selimovd's avatar
    selimovd
    Icon for Most Valuable Professional rankMost Valuable Professional

    Hey RhoFox ,

     

    you can do that with a CALCULATE and then you can tell which column should be considered for the count with the ALLEXCEPT function:

    Count Measure =
    CALCULATE(
        COUNTROWS( myTable ),
        ALLEXCEPT(
            myTable,
            myTable[Project],
            myTable[Date]
        )
    )

     

    If you need any help please let me know.
    If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
     
    Best regards
    Denis
     
  • vanessafvg's avatar
    vanessafvg
    Icon for Community Champion rankCommunity Champion

    you can do a

     

    summarizetable =
    SUMMARIZE ( table[Project], table[Date], "RowCount", COUNTROWS ( table ) )

     

     

  • Hi, RhoFox 

    Please check the below for creating a new column.

     

     

    Count CC =
    VAR currentproject = 'Table'[Project]
    VAR currentdate = 'Table'[Date]
    RETURN
    RANKX (
    FILTER (
    'Table',
    'Table'[Project] = currentproject
    && 'Table'[Date] = currentdate
    ),
    'Table'[Text],
    ,
    ASC
    )

     

     

    • RhoFox's avatar
      RhoFox
      Frequent Visitor

      ooooh it works 😄
      thank you a lot
      I just saw that I still have a problem, I have another column with true / false values, it should only count if the column = true

      • Jihwan_Kim's avatar
        Jihwan_Kim
        Icon for Super User rankSuper User

        Hi, RhoFox 

        Thanks for your feedback.

        Please share your sample pbix file's link here, then I can try to look into it.