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
Anonymous
Not applicable

Group based on condition

Hello Communities,

I am not sure how to group below into power bi power query?

I am trying to group multiple column based on the condition,

I want to group id column if rows numbers are same (Example:20657) and group Answer column by “Y” and “N” and group Area column if both rows are same (Example Americas).

Id

Answer

Area

20657

Y

Americas

20657

N

Americas

20933

N

Americas

20348

Y

Americas

 

 

 

 

 

Expecte Result

Id

Answer

Area

Result

20657

Y

Americas

2

20657

N

Americas

2

20933

N

Americas

1

20348

Y

Americas

1

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Anonymous hope attached will help, you can group by id and also put allrows in group and then expand it.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

@Anonymous hope attached will help, you can group by id and also put allrows in group and then expand it.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Thank you so much Parry.It is working perfectly fine.

v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

You may try to add a custom column.

let
    r = _
in
    Table.RowCount(Table.SelectRows(Source, each [Id] = r[Id] and [Area] = r[Area]))
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Sam,

Please see below i am getting below error,From error i can say it is sheet and table error but i am not sure how dealt with this error?

let
    Source = Excel.Workbook(File.Contents("C:\Users\deletemondya.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Id", Int64.Type}, {"Answer", type text}, {"Area", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let
    r=_
in 
  Table.RowCount(Table.SelectRows(Source,each[Id]=r[Id]
  and [Area]=r[Area]))),
    Custom = #"Added Custom"{0}[Custom]
in
    Custom

commnity.png

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