Forum Discussion
Khramana
3 years agoFrequent Visitor
Word in Column count: unique and percentage
Hello Power BI masters! I have a table "All devices", in which I have columns with device names bu users like this: User name Device model Alex Samsung A3 Helene Samsung A1 Jorge ...
m_dekorte
Resident Rockstar
3 years agoHi Khramana,
You can leverage a Table.RowCount and Table.Group for that.
Copy this code into a new blank query
let
TotalRows = Table.RowCount( Source ),
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsxJrVDSUQpOzC0uzUtXcDRWitWJVvJIzUnNS0UWNwSLe+UXpYOEHQsKclIVDCGK/XPSE9HFgvKTUotKgKJ++dmZiQrGxoYGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"User name" = _t, #"Device model" = _t]),
GroupPerc = Table.Group(Source, {"Device model"}, {{"Count", each Table.RowCount(_)/TotalRows, Percentage.Type}})
in
GroupPerc
First I added a TotalRows = Table.RowCount( Source ),
Then you can use Group By on the ribbon, as key set Device Model
And for the aggregation select Count Rows, update the code in the formula bar.
Table.Group(Source, {"Device model"}, {{"Count", each Table.RowCount(_) /TotalRows, Percentage.Type}})
With this result
Ps. If this helps solve your query please mark this post as Solution, thanks!