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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Group rows within some categories

Hello,

 

I have a table like below:

 

District             ||      Age      ||      Year       ||  Population

Jacksonville      ||        0        ||      2017       ||   4891

............               ||        1        ||      2017       ||   7910

....................

 

Age runs from 0 until 90, Year runs from 2017 until 2020.

 

I want to sum up population grouped into range of certain years years of ages for each district and year. For example, from 0-5, 5-10, 10-15, 16-18, 18-19, 20-25, etc.

 

Example of desired outcome:

 

District          ||     Age    ||  Year    || Population

Jacksonville  ||    0-5      || 2017    ||  12900

Jacksonville  ||     5-10   || 2017    ||   28001

....................

Jacksonville  ||     18-19   || 2017    ||   7876

..............

Jacksonville  ||     75+      || 2017    ||  35984

Miami           ||     0-5       ||  2017   ||  17803

.............

 

How can I achieve this? 

 

Thank you in advance!

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Ok.  Since your bins don't seem to be the same size, you can't do a simple rounding to get them.  The simplest way might be to make a table with 90 rows for each age and their associate bin, and merge that into your query on the Age column.  You can then do a Group By step to get the sum of the newly added Bin column.

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Microsoft Employee
Microsoft Employee

Ok.  Since your bins don't seem to be the same size, you can't do a simple rounding to get them.  The simplest way might be to make a table with 90 rows for each age and their associate bin, and merge that into your query on the Age column.  You can then do a Group By step to get the sum of the newly added Bin column.

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hello Pat,

 

I did as instructed and it has worked well for me. Thanks! 🙂

 

Cheers,

 

P-

mahoneypat
Microsoft Employee
Microsoft Employee

You could do this with the Group/Bin column.  Please see this article.  Doing it in the query editor, would be harder (but doable) and would limit the analyses you can do with your dataset.

Use grouping and binning in Power BI Desktop - Power BI | Microsoft Docs

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hi Pat,

 

Thank you a lot for your information. However I want this to be done with query editor because there is another table that I want to create relationship with this table. That table is from another data source and have the ranges in it so it's best that I get this done. Can you help with the Query Editor?

 

Cheers,

 

P-

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors