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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
PareshDalvi
Frequent Visitor

Apply filter on grouped table using each

Trying to filter grouped data table using each parameter.

 

In following dataset, I want to find if any row has event=ticket in group by session_id

PareshDalvi_0-1679488279038.png

 

= Table.Group(#"Added Custom", {"session_Id", "user_Id"}, {"Count", each Table.RowCount(_), Int64.Type}, {Table.SelectColumns (each [event] = "ticket")})

 

It returns following error.

 

Expression.Error: We cannot convert a value of type List to type Number.
Details:
Value=[List]
Type=[Type]

 

This is what the column contains

PareshDalvi_0-1679487325913.png

 

1 REPLY 1
AlienSx
Super User
Super User

Hello, @PareshDalvi Table.Group expects "nullable number" as 4th parameter (groupKind) while Table.SelectColumns (each [event] = "ticket") does not look like a number and does not return number. Moreover Table.SelectColumns is looking forward to get a table as it's 1st argument while you give it a function (_) => [event] = "ticket".

You have 3 options here:

1. Filter table before Table.Group call

filter_table = Table.SelectRows(#"Added Custom", each [event] = "ticket"),
g = Table.Group(filter_table, {"session_Id", "user_Id"}, {"Count", each Table.RowCount(_), Int64.Type})

2. Filter table inside Table.Group call

= Table.Group(
    Table.SelectRows(
       #"Added Custom", 
       each [event]= "ticket"
    ),
    {"session_Id", "user_Id"}, 
    {"Count", each Table.RowCount(_), Int64.Type}
)

3. Filter table inside Table.RowCount

= Table.Group(
    #"Added Custom", 
    {"session_Id", "user_Id"}, 
    {"Count", 
      each 
        Table.RowCount(
            Table.SelectRows(_, each [event] = "ticket")
        ), 
      Int64.Type}
)

Either should work. I don't know which one is better performance wise - I don't know. 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors