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
Greatbi1
Frequent Visitor

Count of common values - Tricky

Hi All,

 

Need urgent help.

 

I have data like below:

State | Engineer| 

Florida, Johny

Florida, Nick

Indiana, Johny

Indiana, Nick

Florida, Peter

Georgia, Peter

Indiana, Mike

Georgia, Mike

 

I want a pivot table like

 

 

 

 

 

1590429588284529065620.jpg

 

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

Hi @Greatbi1 ,

 

Just merge the table with itself and filter the same states out:

 

the mcode is:

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsvJL8pMSVTSUfLKz8irVIrVQRbzy0zOBgt55qVkJuahKkOIwZUhdAaklqQWgcXcU/OL0jNRxRBafTOzU9GUQYRiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [State = _t, Engineer = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"State", type text}, {"Engineer", type text}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Engineer"}, #"Changed Type", {"Engineer"}, "Changed Type", JoinKind.Inner),
#"Expanded Changed Type" = Table.ExpandTableColumn(#"Merged Queries", "Changed Type", {"State"}, {"State.1"}),
#"Added Custom" = Table.AddColumn(#"Expanded Changed Type", "Custom", each if [State] = [State.1] then 0 else 1),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] = 1)),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Custom"})
in
#"Removed Columns"

 

Capture.PNG

And use a matrix like:Capture1.PNG



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi,

Use the Matrix table,

Which column you want in value table. Please click on the (down side arrow on value) select "Distinct or count" whichever you require.

 

Please refer the below print screen for your reference.

 

Thanks

Pivot.JPG

 

Hey thanks for answering, I was expecting that first column should be state. 

camargos88
Community Champion
Community Champion

Hi @Greatbi1 ,

 

Just merge the table with itself and filter the same states out:

 

the mcode is:

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsvJL8pMSVTSUfLKz8irVIrVQRbzy0zOBgt55qVkJuahKkOIwZUhdAaklqQWgcXcU/OL0jNRxRBafTOzU9GUQYRiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [State = _t, Engineer = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"State", type text}, {"Engineer", type text}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Engineer"}, #"Changed Type", {"Engineer"}, "Changed Type", JoinKind.Inner),
#"Expanded Changed Type" = Table.ExpandTableColumn(#"Merged Queries", "Changed Type", {"State"}, {"State.1"}),
#"Added Custom" = Table.AddColumn(#"Expanded Changed Type", "Custom", each if [State] = [State.1] then 0 else 1),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] = 1)),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Custom"})
in
#"Removed Columns"

 

Capture.PNG

And use a matrix like:Capture1.PNG



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Thanks a lot @camargos88 . Awsome thinking. Hats off to you. I had spent more than a day on it. I can relax now. Thanks a ton.

 

 

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.

Top Solution Authors