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! Request now

Reply
student5000
New Member

Filtering between 2 numbers then getting the sum of another column

Hello,

 

I have a simple table here. 

 Capturepowerbi.PNG

 

What I am trying to do is create a new table that sums the amount when the account number is between 2 numbers. So for example when account is between 4010 and 4200 then sum Amount. The reason that I am looking to do this in query editor rather than on visualization side is because I will need to create many new tables using this same filtering method because I would like to display many of the different summed amounts all at once.

 

Any and all tips are appreciated.

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @student5000 

 

For your current requirement, you can create a duplicate query of the original table in Power Query Editor and execute the following steps:

1. Filter rows by Account column with Number Filters > Between

2. After filtering, select Amount column. Under Transform tab, select Statistics > Sum to calculate the sum of Amount column.

3. In this way, you get a single sum value. You can convert this value to a table.

070102.jpg

 

Attach all codes below.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwUNJRMjIAUrE60SAGmGsI4RpDuUYQLkSxMapiYwMTCNcEzDUBy8YCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Amount = _t, Account = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Amount", Int64.Type}, {"Account", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Account] >= 2000 and [Account] <= 3000),
    #"Calculated Sum" = List.Sum(#"Filtered Rows"[Amount]),
    #"Converted to Table" = #table(1, {{#"Calculated Sum"}})
in
    #"Converted to Table"

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @student5000 

 

For your current requirement, you can create a duplicate query of the original table in Power Query Editor and execute the following steps:

1. Filter rows by Account column with Number Filters > Between

2. After filtering, select Amount column. Under Transform tab, select Statistics > Sum to calculate the sum of Amount column.

3. In this way, you get a single sum value. You can convert this value to a table.

070102.jpg

 

Attach all codes below.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwUNJRMjIAUrE60SAGmGsI4RpDuUYQLkSxMapiYwMTCNcEzDUBy8YCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Amount = _t, Account = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Amount", Int64.Type}, {"Account", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Account] >= 2000 and [Account] <= 3000),
    #"Calculated Sum" = List.Sum(#"Filtered Rows"[Amount]),
    #"Converted to Table" = #table(1, {{#"Calculated Sum"}})
in
    #"Converted to Table"

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

AlexisOlson
Super User
Super User

I'd strongly recommend against trying to "create many new tables using this same filtering method" in general. Can you show us what your final intended display is?

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.