Forum Discussion

Freefly's avatar
Freefly
Frequent Visitor
8 years ago
Solved

Counting number combinations in two columns

Hi, trying to count how many time a specif pair fo data occurs in two colums. I dont know what combination that my occur and the point is to find out what pair or combination that is most frequent.

 

Tabel 1

Data1   Data2          

1          2

3          5

1          2

3          4

6          1

1          2

 

Mesure

Data1   Data2   Count         

1          2            3

3          5            1

3          4            1

6          1            1

 

Thanks

 

  • Freefly

     

    You can also us this MEASURE

    Measure =
    CALCULATE (
        COUNTROWS ( TableName ),
        ALLEXCEPT ( TableName, TableName[Data1], TableName[Data2] )
    )

     

6 Replies

  • I used Group by in the Edit Queries and grouped the data with data 1 and data 2.

    Is this what you want?

     


    = Table.Group(#"Changed Type", {"data 2", "data 1"}, {{"Count", each Table.RowCount(_), type number}})

     

  • augustindelaf's avatar
    augustindelaf
    Impactful Individual

    Freefly I found a way to count that in Power BI Desktop

     

    1. Be sure your columns are tagged as text.

     

    2. You have to concatenate columns Data1 and Data2 (see image):

      Use the function "add a Custom Column" and Concatenate your fields :

     

     

     

    Now it should look like that :

     

     

     Then, use the function "Group By" (see image, in red):

     

    Group by "Concatenate",

    Operation : "Count"

     

    You now have your "Counting" operation that is automated ! See image

     

    • Zubair_Muhammad's avatar
      Zubair_Muhammad
      Community Champion

      Freefly

       

      You can also us this MEASURE

      Measure =
      CALCULATE (
          COUNTROWS ( TableName ),
          ALLEXCEPT ( TableName, TableName[Data1], TableName[Data2] )
      )