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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
mumair
Helper I
Helper I

How to Count

Wondering how to do something as follows:

 

Order # | Error

Order 1 | Something

Order 1 | Something else

Order 2 | null

Order 3 | Something

 

I want a column or a table that says something like this:

Order # | Error Count

Order 1 | 2

Order 2 | 0

Order 3 | 1

 

Any ideas?

1 ACCEPTED SOLUTION

Like this:

 

Specializing in Power Query Formula Language (M)

View solution in original post

6 REPLIES 6
MarcelBeug
Community Champion
Community Champion

You can use "Group By" in the query editor.

In order to create base code, you can choose to sum the "Error" column and then adjust the generated code to the code below.

 

Group By Order.png

 

let
    Source = Input,
    #"Grouped Rows" = Table.Group(Source, {"Order #"}, {{"Error Count", each List.NonNullCount([Error]), Int64.Type}})
in
    #"Grouped Rows"
Specializing in Power Query Formula Language (M)

I tried to do that, but it wouldn't let me. That is because the error column is text, so it is not letting me use the sum operator

Ah, forgot to tell. Sure you will get errors at first, just ignore these and adjust the code, then you'll be fine.

Specializing in Power Query Formula Language (M)

Like this:

 

Specializing in Power Query Formula Language (M)

Wow, thank you so much, this was really helpful.

 

One last question. I want to either append this column to the original table, or create a new table without altering the first table. How do I do this?

Just save & load the query with a new name, then you'll have your new table.

Specializing in Power Query Formula Language (M)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.