Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hi,
I'm trying to replicate countif excel function into powerquery.
=COUNTIF(C:C,C3)
End result should be as below
| Item | Count of Items |
| A | 4 |
| A | 4 |
| A | 4 |
| A | 4 |
| B | 4 |
| B | 4 |
| B | 4 |
| B | 4 |
| B | 4 |
Solved! Go to Solution.
=let a=Table.Buffer(Table.Group(PreviousStepName,"Item",{"n",Table.RowCount})) in Table.AddColumn(PreviousStepName,"Count of Items",each a{[Item=[Item]]}[n])
=let a=Table.Buffer(Table.Group(PreviousStepName,"Item",{"n",Table.RowCount})) in Table.AddColumn(PreviousStepName,"Count of Items",each a{[Item=[Item]]}[n])
Is that a mistake on the B rows?
If I understand correctly, you can do it like this:
Do a 'Group By' with only 'All Rows'
Then add a custom Column using Table.RowCount on the column that the previous step created.
Expand the rows. That's it.
Table.AddColumn(#"previousStep", "Count of Items", each List.Count(Table.SelectRows(#"previousStep", (x) => x[Item] = "A")[Item]))
gets you...
Table.AddColumn(#"Changed Type", "Count of Items", each List.Count(Table.SelectRows(#"Changed Type", (x) => [Item] = x[Item])[Item]))
gets you...
Proud to be a Super User! | |
Unfortunately this does not work. Below is the formula Im using
= Table.AddColumn(#"Added Unit", "Count of Items", each List.Count(Table.SelectRows(#"Added Unit", (x) => [a.itm_nbr]=[a.itm)[a.itm]))
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 10 | |
| 9 | |
| 7 | |
| 5 | |
| 5 |