March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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"
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
114 | |
76 | |
57 | |
52 | |
44 |
User | Count |
---|---|
167 | |
117 | |
63 | |
57 | |
50 |