Measure calculation for Individual items in Colums

Ankitsahgal

New Member
Joined
Dec 19, 2015
Messages
11
Hello everyone,

I am trying to build a P&L that I can slice and dice as required. I get data for multiple sites and need to ability to into with a few clicks.

I have the data in the below format:

Site NameCategoryPeriod 1Period 2Period 2Period 3
DeltaDrink Sales5101520
DeltaFood Sales1057.515
DeltaDrink COS2539
DeltaFood COS6125
BetaDrink Sales610811
BetaFood Sales8746
BetaDrink COS3421
BetaFood COS6432

<tbody>
</tbody>
















I am trying to calculate the Gross profit which is Drink sales - Drink COS , Food sales -Food COS

I have come up the below:

Cost of Sales:= Calculate([Sum of Period 1],[category]="Drink Sales")-Calculate([Sum of Period 1],[category]="Drink COS")

But obviously I will have to create the same measure for all the periods ?

Is there a way to create a single measure as opposed measures for so many periods?

Thank you

Ankit
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
You should first unpivot the data so it looks like this

site. Cat. Period. Value.
A. Cc. 1. 5
A. Cc. 2. 7
etc

thenypu can just put period on your pivot table. Use Power Query to unpivot the data
 
Upvote 0
Solution in Power Query

Paste in Blank Query in Advanced Editor next code:

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Site Name", type text}, {"Category", type text}, {"Period 1", Int64.Type}, {"Period 2", Int64.Type}, {"Period 22", type number}, {"Period 3", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Site Name", "Category"}, "Attribute", "Value"),
    #"Sorted Rows" = Table.Sort(#"Unpivoted Other Columns",{{"Attribute", Order.Ascending}, {"Site Name", Order.Ascending}}),
    #"Pivoted Column" = Table.Pivot(#"Sorted Rows", List.Distinct(#"Sorted Rows"[Category]), "Category", "Value", List.Sum),
    #"Reordered Columns" = Table.ReorderColumns(#"Pivoted Column",{"Site Name", "Attribute", "Drink Sales", "Drink COS", "Food COS", "Food Sales"}),
    #"Added Custom" = Table.AddColumn(#"Reordered Columns", "Drink Gross", each [Drink Sales]-[Drink COS]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Food Gross", each [Food Sales]-[Food COS]),
    #"Renamed Columns1" = Table.RenameColumns(#"Added Custom1",{{"Attribute", "Period"}}),
    #"Added Custom2" = Table.AddColumn(#"Renamed Columns1", "Gross Profit", each [Drink Gross]+[Food Gross])
in
    #"Added Custom2"
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top