Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
How can I get a count of every value in a column in Power Query? More like Countif in Excel. This is certainly doable using DAX but I am interested in doing this in Power Query.
I am looking for the below "Count" field as an output using the Fruit field.
Fruit Count
Apple 3
Orange 1
Banana 2
Apple 3
Apple 3
Banana 2
Solved! Go to Solution.
Hi,
One of ways to achieve this in Power Query Editor is to write M code something like below.
Please check the below and the attached pbix file.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyElVitWJVvIvSsxLhzCdEvOAEMxEyCNYMOlYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Fruit = _t]),
#"Merged Queries" = Table.NestedJoin(Source, {"Fruit"}, Source, {"Fruit"}, "Source", JoinKind.LeftOuter),
#"Added Custom" = Table.AddColumn(#"Merged Queries", "Rowcount", each Table.RowCount ( [Source] ), Int64.Type),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Fruit", "Rowcount"})
in
#"Removed Other Columns"
Hi,
One of ways to achieve this in Power Query Editor is to write M code something like below.
Please check the below and the attached pbix file.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyElVitWJVvIvSsxLhzCdEvOAEMxEyCNYMOlYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Fruit = _t]),
#"Merged Queries" = Table.NestedJoin(Source, {"Fruit"}, Source, {"Fruit"}, "Source", JoinKind.LeftOuter),
#"Added Custom" = Table.AddColumn(#"Merged Queries", "Rowcount", each Table.RowCount ( [Source] ), Int64.Type),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Fruit", "Rowcount"})
in
#"Removed Other Columns"
@kabra_ashish , Duplicate this table or create a new table using the fruit column.
Then group by and get count.
Merge the second table with the first one
https://docs.microsoft.com/en-us/power-query/group-by
Append : https://radacad.com/append-vs-merge-in-power-bi-and-power-query
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.