Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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?
Solved! Go to Solution.
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.
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
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.
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.
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.
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.
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
User | Count |
---|---|
139 | |
113 | |
103 | |
73 | |
63 |
User | Count |
---|---|
136 | |
125 | |
107 | |
70 | |
61 |