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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.