Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Freefly
Frequent Visitor

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

 

1 ACCEPTED SOLUTION

@Freefly

 

You can also us this MEASURE

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

 

CountPairs.png


Regards
Zubair

Please try my custom visuals

View solution in original post

6 REPLIES 6
v-jiascu-msft
Employee
Employee

Hi @Freefly,

 

Could you please mark the proper answer as solution?

 

Best Regards!
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
augustindelaf
Impactful Individual
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 :

fffffffff.PNG

 

 

 

Now it should look like that :

fffffffff.PNG

 

 

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

fffffffff.PNG

 

Group by "Concatenate",

Operation : "Count"

 

You now have your "Counting" operation that is automated ! See imagefffffffff.PNG

 

@Freefly

 

You can also us this MEASURE

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

 

CountPairs.png


Regards
Zubair

Please try my custom visuals
Sachy123
Helper V
Helper V

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}})

 

Thanks for a quick anser.
Is that the exact syntax? tried to put it in under In in the advace editor but got error

Like this

https://msdn.microsoft.com/en-us/library/mt260774.aspx#Arguments

 

PrefeblyI dont what to alter the columns since I used them for other things as well and these are just two of many columns in the DB

 

 

Perhaps you can use Group BY in the Transform tab 

 

Solution.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.