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
Anonymous
Not applicable

Gross Margin Column For Customer without Creating New Table

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.

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

@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! Smiley Happy

 

View solution in original post

4 REPLIES 4
Sean
Community Champion
Community Champion

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 Smiley Happy

Anonymous
Not applicable

@Sean

 

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:

 

CustomerItemSalesCostCustomer GM
A1805050.00%
A21004050.00%
B1755045.95%
B21105045.95%

 

Sean
Community Champion
Community Champion

@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! Smiley Happy

 

Anonymous
Not applicable

@Sean

Just what I wanted. Thanks!

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.