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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Sum based on multiple columns

Hello,

I am trying to sum the number of occurences by groups of other columns to get an idea of how often they occur. Below is an example of my data is set-up. 

IHargrave_0-1641592372561.png

I wish to sum by both product and location such that it results in:

IHargrave_1-1641592465330.png

Should a calculation like this be done within the query editor or in DAX?

 

Thanks guys!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hello @Anonymous ,

There is a simple solution for your group. You just have to put all there columns Product, Location and Sales in Table and it will automatically group by Product and Location and if you want count than add one measure in table as below.
Group by Sum :-

NeelPatel_0-1641622663635.png 

NeelPatel_2-1641622700379.png

Group By Count :-

NeelPatel_3-1641622725374.png

NeelPatel_4-1641622740222.png

Thanks

 

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hello @Anonymous ,

There is a simple solution for your group. You just have to put all there columns Product, Location and Sales in Table and it will automatically group by Product and Location and if you want count than add one measure in table as below.
Group by Sum :-

NeelPatel_0-1641622663635.png 

NeelPatel_2-1641622700379.png

Group By Count :-

NeelPatel_3-1641622725374.png

NeelPatel_4-1641622740222.png

Thanks

 

 

 

Anonymous
Not applicable

Ah, that worked perfectly. Not sure what issue I had ran into previously too, but I couldn't get that to work for the life of me. Thanks again!

SteveHailey
Solution Specialist
Solution Specialist

Hello @Anonymous. You could do it either place.
 

In the query editor, you would select the Fruit column, then hold down Ctrl and select the City column. Then on the Transform tab of the ribbon, on the far left choose Group By. The defaults should be what you want in this case. They'll look like this:

SteveHailey_0-1641593471328.png

And the results will look like this:

SteveHailey_1-1641593488250.png

 

With DAX, you could create a New Table, and use code like the following:

 

Table =
ADDCOLUMNS (
    SUMMARIZE ( Data, Data[Fruit], Data[City] ),
    "Count", CALCULATE ( COUNTROWS ( Data ) )
)

 

The results will look like this:

SteveHailey_2-1641593579307.png

-Steve

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.