Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hello,
I am looking to create a column that has the total gross margin for the customer on each row. This is transactional data, so the customers are not unique in the columns. How I would typically do this is create a new table, summarize the current one with Customer, sum of sales, and sum of cost. Create a new column for customer margin, create a relationship with the original data, and create a new column in the original data using the related function.
This works, but it would be nice not having to create a new table for any time I need to do this. I'm assuming CALCULATE and ALL will be used.
Thanks for any help.
Solved! Go to Solution.
@Anonymous
Here's the COLUMN formula that should do it
GM % COLUMN = DIVIDE ( CALCULATE ( SUM ( 'Table'[Sales] ), ALLEXCEPT ( 'Table', 'Table'[Customer] ) ) - CALCULATE ( SUM ( 'Table'[Cost] ), ALLEXCEPT ( 'Table', 'Table'[Customer] ) ), CALCULATE ( SUM ( 'Table'[Sales] ), ALLEXCEPT ( 'Table', 'Table'[Customer] ) ), 0 )
Hope this helps!
Well the process should be pretty similar except the way you created the columns in the new Table using SUMMARIZE
Now create Measures instead
Measure to Sum the Sales
Measure to Sum the Costs
Measure for Profit = Measure to Sum the Sales - Measure to Sum the Costs
Create a Table Visual - place Customer in the Rows and the Measures in the Values
If you encounter problems come back here and ask?
I think you'll only need CALCULATE and ALL, ALLSELECTED, ALLEXCEPT if you are doing %
Again your question was pretty general so without any further specifics that's my 2 cents worth
Thanks for the response. I am wanting to actually have these as columns in the values, not just a visual. ie getting the last column to calculate in the values tab:
Customer | Item | Sales | Cost | Customer GM |
A | 1 | 80 | 50 | 50.00% |
A | 2 | 100 | 40 | 50.00% |
B | 1 | 75 | 50 | 45.95% |
B | 2 | 110 | 50 | 45.95% |
@Anonymous
Here's the COLUMN formula that should do it
GM % COLUMN = DIVIDE ( CALCULATE ( SUM ( 'Table'[Sales] ), ALLEXCEPT ( 'Table', 'Table'[Customer] ) ) - CALCULATE ( SUM ( 'Table'[Cost] ), ALLEXCEPT ( 'Table', 'Table'[Customer] ) ), CALCULATE ( SUM ( 'Table'[Sales] ), ALLEXCEPT ( 'Table', 'Table'[Customer] ) ), 0 )
Hope this helps!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
89 | |
82 | |
65 | |
51 | |
31 |
User | Count |
---|---|
119 | |
113 | |
72 | |
62 | |
46 |