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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
mattbstrong
Helper IV
Helper IV

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
AllisonKennedy
Super User
Super User

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.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as 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 C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

4 REPLIES 4
AllisonKennedy
Super User
Super User

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.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as 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 C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@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 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as 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 C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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