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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
SanketBhagwat
Solution Sage
Solution Sage

Sum of all Column Values.

I want to create a measure that will give me a sum of all column values present in my table.

Consider I have a table called 'Sales' and it has more than 1 columns named as 'Sales1', 'Sales2',...'SalesN'.

The data type of all columns is same and all columns contain a numeric value.

Now, if I want to create a measure to show sum of all column values, then I will have to use SUM  function again and again.

If there are 2 or 3 columns, then it might be efficient to use that function.

But if in the case the table has many columns, at that time what could be done?

 

If someone knows a way to do this, then please do let me know.

 

Regards,

Sanket Bhagwat. 

2 ACCEPTED SOLUTIONS
Fowmy
Super User
Super User

@SanketBhagwat 

The best approach is to unpivot all your sales column into one column then it is easy. If you need a DAX solution then add the following column to your table

Total Sales = SUMX( {[Sales 1],[Sales 2],[Sales 3] },[Value] )

Sample Data

Fowmy_0-1622121384996.png
Create a measure to add the new column to get the total overall sales:

Overall Sales = SUM(Table6[Total Sales])

 

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

@SanketBhagwat In response to your private message, @Fowmy 's solution does not require unpivoting the columns although I agree that is the best way. You could still create your buckets because the Attribute column would provide the original column heading.

 

You could also use DAX Unpivot if you absolutely do not want to do it in Power Query and essentially achieve the same effect: https://community.powerbi.com/t5/Quick-Measures-Gallery/DAX-Unpivot/m-p/574832#M256

 

I really do not see an application for looping here.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Fowmy
Super User
Super User

@SanketBhagwat 

The best approach is to unpivot all your sales column into one column then it is easy. If you need a DAX solution then add the following column to your table

Total Sales = SUMX( {[Sales 1],[Sales 2],[Sales 3] },[Value] )

Sample Data

Fowmy_0-1622121384996.png
Create a measure to add the new column to get the total overall sales:

Overall Sales = SUM(Table6[Total Sales])

 

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi @Fowmy 

Your approach can be one solution to that.

But I have been instructed not to unpivot and see if we can use loops in there.

I have a table with 56 columns and I need to create buckets.

1 bucket of 31 columns and so.

 

I was reading 'https://community.powerbi.com/t5/Community-Blog/For-and-While-Loops-in-DAX/ba-p/636314' this article for same, but haven't got a perfect solution.

@SanketBhagwat In response to your private message, @Fowmy 's solution does not require unpivoting the columns although I agree that is the best way. You could still create your buckets because the Attribute column would provide the original column heading.

 

You could also use DAX Unpivot if you absolutely do not want to do it in Power Query and essentially achieve the same effect: https://community.powerbi.com/t5/Quick-Measures-Gallery/DAX-Unpivot/m-p/574832#M256

 

I really do not see an application for looping here.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg.

 

Exactly what I wanted to hear.

I also thought that looping is not a feasible option in here.

Thanks a ton for confirming the same.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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