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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sakhigarg
Regular Visitor

Total Across Row

Hi all,

 

I'm trying to get total across rows. I need a column, where each row has a value of summation across rows.

 

For example, in below screenshot, I need a column with total sales for each month. So basically it should add sales of each category for each month giving following results: So i need to calculate "Total Sales" column.

 

MonthFurnitureOffice SuppliesTechnologyTotal Sales
JAN 3.52 3.52
FEB  597.1314.99612.12
MARCH 585.12238823.12

APRIL

 303.0399.99403.02
JUNE663.9841.05 705.03
JULY 589.48257.98847.46
SEP 276.2659.98336.24

 

I was to create a DAX for this. Is there a way to so this? Also the values in each category is calculated using measure names "Sales LTM". 

 

I'm sharing the link to my pbix file for your reference. Its on "page 2".

 

https://1drv.ms/u/s!AhWE64mO-7d3h3OqttDxPCRMzJsZ

 

Powerbi-1.png

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

You can get your total with this measure, but when you add it to matrix it will add it for each Category.  Adding it as a single column is not doable.

 

Sales LTM All Cat = CALCULATE([sales LTM], ALL(Orders[Category]))
 
Regards,
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

11 REPLIES 11
mahoneypat
Employee
Employee

You can get your total with this measure, but when you add it to matrix it will add it for each Category.  Adding it as a single column is not doable.

 

Sales LTM All Cat = CALCULATE([sales LTM], ALL(Orders[Category]))
 
Regards,
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


Hey @mahoneypat , Thanks for the solution. It works. Yeah I'm understanding thats it not possible in powerBI just to add measure in column in a matrix. But atleast I got solution of getting the correct total sales value.

 

Let me know if there is a way I can add measure field in column or rows instead of values. Again thats for the help.

You may be interested in the Show On Rows feature.

You Can Now Put Values On Rows In Power BI – Data Savvy

 

Also, you can turn off auto size columns in the column header options, and reduce the width of any column you don't want to show until it is gone.

Regards,

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


amitchandak
Super User
Super User

@sakhigarg , You can enable column sub total , will that do ?

Screenshot 2021-01-04 19.18.24.png

@amitchandak Actualy I want to create a DAX for this. Because I will further use this total sales in my other calculation. So subtotal option won't work in this case.

mahoneypat
Employee
Employee

I downloaded your pbix.  When I just turn on Column subtotals in the matrix format options, I get your desired results.  If those totals are not correct, this measure could be used instead.

 

Category Sum = SUMX(VALUES(Orders[Category]), [sales LTM])
 
Regards,
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


Hi @mahoneypat,

Thanks for the reply. I don't want to use the subtotal option as I will use this total sales column in other calculations as well. Also I tried the code you have given and created "total sales". But when I add the measure in my matrix, it shows the result like below screenshot:

 

powerbi-3.png

Basically it shows total sales for individual category. Not overall month sales. I want the result we get from subtotals, but for that I want to create DAX.

 

amitchandak
Super User
Super User

@sakhigarg , No access to the file. What are your base table structure

As of now, it seems like

Sum(Table[Furniture])+Sum(Table[Office Supplies]) + Sum(Table[Technology])

 

or add a total column to the matrix (column total)

 

if you looking for a hybrid table

https://community.powerbi.com/t5/Community-Blog/Creating-a-custom-or-hybrid-matrix-in-PowerBI/ba-p/1...
https://community.powerbi.com/t5/Quick-Measures-Gallery/The-New-Hotness-Custom-Matrix-Hierarchy/m-p/...

vote for Hybrid Table
https://ideas.powerbi.com/ideas/idea/?ideaid=9bc32b23-1eb1-4e74-8b34-349887b37ebc

 

 

Hi @amitchandak 

 

Thanks for the reply.

Firstly, I'm not able to use SUM() function because the values in each category is calculated using DAX. The maesure name is "Sales LTM". I believe that we cannot use a measure felid with SUM() function.

 

Secondly, i want a dynamic solution. Because if you notice in my pbix file as well as screenshot, I have added a slicer name "State". So for each state, category will change. So your solution will not work here.

@sakhigarg , i was not able to access the pbix, can share again.

@amitchandak  I'm sharing the link again. Open it in google crome. It will be open then.

 

https://1drv.ms/u/s!AhWE64mO-7d3h3OqttDxPCRMzJsZ

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.