Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Help please!
I have a data set that I am trying to count the unique number of rows that have the same data regardless of order.
Sample below:
Column1 | Column2 |
A | B |
A | B |
C | D |
C | D |
B | A |
B | A |
D | C |
D | C |
Solved! Go to Solution.
I take it that the number of unique rows in your example is 2, since (A,B) is considered equivalent to (B,A) etc.
You could write a measure like this:
Distinct Combinations =
COUNTROWS (
DISTINCT (
SELECTCOLUMNS (
YourTable,
"Value1", MIN(YourTable[Column1], YourTable[Column2]),
"Value2", MAX(YourTable[Column1], YourTable[Column2])
)
)
)
I take it that the number of unique rows in your example is 2, since (A,B) is considered equivalent to (B,A) etc.
You could write a measure like this:
Distinct Combinations =
COUNTROWS (
DISTINCT (
SELECTCOLUMNS (
YourTable,
"Value1", MIN(YourTable[Column1], YourTable[Column2]),
"Value2", MAX(YourTable[Column1], YourTable[Column2])
)
)
)
You can use
Unique Count = COUNTROWS(SUMMARIZE(Table, Table[Column1], Table[Column2]))
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@KimberlyHcan be done using pqwry
let
Source = Web.BrowserContents("https://community.powerbi.com/t5/Desktop/Unique-count-of-rows-any-order-using-two-columns/m-p/1640243#M658636"),
#"Extracted Table From Html" = Html.Table(Source, {{"Column1", "TABLE:nth-child(2) > * > TR > :nth-child(1)"}, {"Column2", "TABLE:nth-child(2) > * > TR > :nth-child(2)"}}, [RowSelector="TABLE:nth-child(2) > * > TR"]),
#"Changed Type" = Table.TransformColumnTypes(#"Extracted Table From Html",{{"Column1", type text}, {"Column2", type text}}),
#"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Column1", type text}, {"Column2", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type1", {"Column1", "Column2"}, {{"ad", each _, type table [Column1=nullable text, Column2=nullable text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each let x=[ad], y= Table.AddIndexColumn(x, "Rep", 1, 1, Int64.Type) in y),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"Column1", "Column2", "Rep"}, {"Column1", "Column2", "Rep"})
in
#"Expanded Custom"
User | Count |
---|---|
119 | |
78 | |
58 | |
52 | |
46 |
User | Count |
---|---|
170 | |
117 | |
63 | |
58 | |
51 |