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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

Sum column values by same row value

Hi there,

 

I have a table which reflects my itemised sales data and includes the following:

 

  • Order Number
  • Item Code
  • Item Description
  • Qty
  • Total Sale

The same order number can be present on multiple rows as it would be a single order for multiple items. I want to create a calculated column that sums all of the Total Sales values by Order Number, to give me a total sale by Order Number value.

 

What is the DAX for this?

 

Thanks.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi Daniel,

 

I found the error I made, there was a single ")" I missed in the formlua which was difficult to spot...

 

However, I found that the correct formula was in fact to use EARLIER and not MAX.

 

Thanks,

Paul

View solution in original post

6 REPLIES 6
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

Based on my test, you could refer to below steps:

Sample data:

1.PNG

Create below measure:

Measure = CALCULATE(SUM(Table1[Total Sales]),FILTER(ALL('Table1'),'Table1'[Order Number]=MAX('Table1'[Order Number])))

Result:

1.PNG

You could also download the pbix file to have a view.

 

Regards,

Daniel He

Community Support Team _ Daniel He
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 Daniel,

 

I found the error I made, there was a single ")" I missed in the formlua which was difficult to spot...

 

However, I found that the correct formula was in fact to use EARLIER and not MAX.

 

Thanks,

Paul

Anonymous
Not applicable

Now I have a different issue but related to the same source formula.

 

Now that I have the correct sum of the line items per PO, I need to get an average of those totals. When I place the field in a Card and specify for it to be presented as an average, it gives me an incorrect answer. When I export the table with PO numbers and totals for those POs I get the correct average which is lower than the Card.

 

Now if I create the below Measure the average is calculated correctly. Why?

 

Average PO Spend = AVERAGEX(SUMMARIZE(Table, Table[PO], "to Average", [Spend Measure]), [Spend Measure])

 

Spend Measure = CALCULATE([Total Spend], FILTER(Table, Table[PO]))

Anonymous
Not applicable

Hi Daniel,

 

I used your formula but PBI is giving me an error stating there are too few arguments for the FILTER function and it requires a minimum of 2?

 

Remembering that I need this to be a New Column and not a Measure, would that make a difference with the formula required?

 

Sorry, still very new to DAX and trying to get my head around it all.

 

Thanks,

Paul

Hi @Anonymous,

Could you please offer me a sample file and post your desired result if possible? So I could test for your desied result.

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

 

In your Table visual, drag Order Number and write this measure

 

=SUM(Data[Total Sale])

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.