cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper III
Helper III

All Columns?

I have a table with several columns in it. For example: A,B,C,D,E,F,G,... The number of columns will vary.

I need to create a customer column where the new column is equal to A-(B+C+D+E+F+G...) Basically, I need to sum all the columns and then subtract column A.

 

Can someone help me with how to do this as a custom coolumn and as a measure?

1 ACCEPTED SOLUTION
Super User III
Super User III

My suggestion would be to unpivot the B,C,D,... columns by using Unpivot OTHER columns in Power Query.

 

So click Transform Data to open power query, add an Index Column if you don't have one already.

 

Select column A and all attribute columns, then Unpivot Other Columns

 

Close & Apply. Then create a matrix visual with [Index] in Rows, and create a new Measure:

Measure = SUM(table[columnA]) - SUM(table[value])

 

and put the Measure in values of the matrix.

 

There are other variations, but this should hopefully inspire you to get a solution that works. Come back with any questions.

 


______________


Check out my Data Stories Gallery Christmas Report: Are you on Santa's Naughty or Nice List?

______________


Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 


If you found this post helpful, please give Kudos.


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


www.excelwithallison.com

View solution in original post

4 REPLIES 4
Super User III
Super User III

My suggestion would be to unpivot the B,C,D,... columns by using Unpivot OTHER columns in Power Query.

 

So click Transform Data to open power query, add an Index Column if you don't have one already.

 

Select column A and all attribute columns, then Unpivot Other Columns

 

Close & Apply. Then create a matrix visual with [Index] in Rows, and create a new Measure:

Measure = SUM(table[columnA]) - SUM(table[value])

 

and put the Measure in values of the matrix.

 

There are other variations, but this should hopefully inspire you to get a solution that works. Come back with any questions.

 


______________


Check out my Data Stories Gallery Christmas Report: Are you on Santa's Naughty or Nice List?

______________


Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 


If you found this post helpful, please give Kudos.


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


www.excelwithallison.com

View solution in original post

@AllisonKennedy , thank you for your help so far. When I unpivot the data do I include the index in the columsn I select before I unpivot?

 

Also, I was really hoping to store this ne calculated value in the table and not just display it on the reports. I thought I could do this using a measure. Is this right? Or do I need to do something in the query editor in M code?

Hi @mattbstrong ,

I created a sample pbix file with different methods, please check whether they are what you want. If no, please provide some sample data(exclude sensitive data) and your expected result with examples. Thank you.

all columns.png

Any comment or problem, please feel free to let me know.

Best Regards
Community Support Team _ Rena Ruan
If this post helps, then please consider Accept it as the solution to help the other members find it more.

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

@mattbstrong 

Yes, select the Index column as one of the attribute columns. 

 

I suppose it is technically possible to create a DAX calculated column that will store the calculation in the table. Measures are not stored in the table though, but rather use the context of the visualizations you create in the report. Why are you wanting this though? It will not impact the raw data source. 

Power BI Order of Operations 

 


______________


Check out my Data Stories Gallery Christmas Report: Are you on Santa's Naughty or Nice List?

______________


Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 


If you found this post helpful, please give Kudos.


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


www.excelwithallison.com

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors