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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Grand total calculation

Hi Guys,

        I am new to power bi and i need to calculate the grand total in a column. I an having a measure displayed in the table format. measure = SUM(Table1[Sales Amount])/SUM(Table2[Qty]). the Sales amolunt is 920313461.42 the Qty is 3280190.

When i use this measure i am getting the correct values row wise but when you see the Grand total of the colum measure it is wrong.

It divides the sum of the total sales amount with the total sum of the qty and displays it as 280.6. But here i need to get the grand total of the column. How such a small no is displayed i am confused.  I need the grand total of the column. PLease help me with it

Capture.PNG

2 ACCEPTED SOLUTIONS
JustJan
Responsive Resident
Responsive Resident

Hi @Anonymous ,

 

It is probably because the intermediate table is calculating a Blank or Empty value. For instance line 5 in your table.

 

Adjust the measure to exclude these result or adjust your filters to exclude these situations.

 

If you want to change the measure, you can add a filter statement to the Ratio New measure.

 

2020-01-19 11_09_43-Window.jpg

 

Since I don't have your data is a bit of guessing, but a blank value is most likely, otherwise adjust the filter accordingly.

 

Jan 

View solution in original post

Hi,

Modify your existing measure to

measure = IFERROR(SUM(Table1[Sales Amount])/SUM(Table2[Qty]),BLANK())

Now my measure will work.


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

View solution in original post

10 REPLIES 10
JustJan
Responsive Resident
Responsive Resident

Hi @Anonymous ,

 

It is probably because the intermediate table is calculating a Blank or Empty value. For instance line 5 in your table.

 

Adjust the measure to exclude these result or adjust your filters to exclude these situations.

 

If you want to change the measure, you can add a filter statement to the Ratio New measure.

 

2020-01-19 11_09_43-Window.jpg

 

Since I don't have your data is a bit of guessing, but a blank value is most likely, otherwise adjust the filter accordingly.

 

Jan 

Hi @JustJan ,

            Thanks for your Help its working now. Thanks for your time.

Ashish_Mathur
Super User
Super User

Hi,

Try this

=IF(HASONEVALUE(Data[rName]),[Measure],SUMX(SUMMARIZE(VALUES(Data[rName]),Data[rName],"ABCD",[Measure]),[ABCD]))

rName if what i see as the title of the first column in the image.

Hope this helps.


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

@Ashish_Mathur  Hi,

           I had tried your Query but its showing the grand total as Infinity.Capture1.PNG

Hi,

Modify your existing measure to

measure = IFERROR(SUM(Table1[Sales Amount])/SUM(Table2[Qty]),BLANK())

Now my measure will work.


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

@Ashish_Mathur  Hi,

                          Thanks for you solution its working

You are welcome.


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

You can use the above solution. The problem is known as the sum of averages. You can also refer

https://community.powerbi.com/t5/Desktop/SUM-of-AVERAGE/td-p/197013

I this case instead of doing avg, you have to use sum(a)/sum(b) in the first step.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
JustJan
Responsive Resident
Responsive Resident

Hi Sathish, 

 

The reason for the total to be 280.6 is because PBI does not sum to row values in the Grand Total line, but it recalculates the formula. So the 280.6 is correct. You need a slightly more complex measure to sum your row values.

 

I used some sample data and I have rows per product category.

I created the following measures:  

Sales Amount := SUMX ( Sales, Sales[Quantity] * Sales[Net Price] )

Sales Qty := sum(Sales[Quantity])

Ratio := DIVIDE([Sales Amount], [Sales Qty])

Ratio New :=
Var CategoryRatio =
ADDCOLUMNS ( SUMMARIZE ( 'Sales', 'Product'[Category]), "Ratio", [Ratio] )
var Result = SumX ( CategoryRatio, [Ratio])
return
Result

Basically the intermediate table CategoryRatio calculates the row values, which are than summed to provide the grand total

 

 

2020-01-18 08_27_19-Window.jpg

Just translate it to your own data model / report

 

Hope this helps

 

Jan 

 

if this is a solution for you, don't forget to mark it as such. (and kudos are always welcome too),  thanks

 

Anonymous
Not applicable

@JustJan hi,

               I had tried your Query but its showing the grand total as infinity.Capture1.PNG

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.