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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
marzeind
Frequent Visitor

Calculate team benefit per month for each product type

Hi, first of all, sorry for my english.

 

I need to calculate total benefit for each team per month with different product types. My data look like this tabel:

IDProduct TypeProduction DateShipping DateManufacturerYearMonth 1Benefit YearMonth 1YearMonth 2Benefit YearMonth 2YearMonth 3Benefit YearMonth 3Split Benefit to Manufacture ASplit Benefit to Manufacture BSplit Benefit to Manufacture C
1XXX1/1/20201/2/2020AFeb-202440Mar-204135Apr-202750100%  
2YYY1/15/20201/16/2020B  Feb-203900Mar-20145460% 40%
3ZZZ1/29/20201/30/2020CApr-204663May-202826Jun-20287230%50%20%
4YYY2/12/20202/13/2020CMay-203460Jun-202305Jul-203518  100
5ZZZ2/26/20202/27/2020B    Aug-204137 100 

 

I need to summary those data for each team, month, and product type, with table like this (table below). Total benefit should be calculate based on manufacture share/split (see table above, 3 last column), different production ID has different split percentage for each manufacturer. 

 

I still can't find formula in dax to solve my problem😢. If anyone has experiences or has ideas to solve my problem, I really appreciated.

 

ManufacturerMonthProduct TypeTotal Benefit
AJanXXX 
AFebXXX 
AMarXXX 
AAprXXX 
AMayXXX 
AJunXXX 
AJulXXX 
AAugXXX 
AJanYYY 
AFebYYY 
AMarYYY 
AAprYYY 
AMayYYY 
AJunYYY 
AJulYYY 
AAugYYY 
AJanZZZ 
AFebZZZ 
AMarZZZ 
AAprZZZ 
AMayZZZ 
AJunZZZ 
AJulZZZ 
AAugZZZ 
BJanXXX 
BFebXXX 
BMarXXX 
BAprXXX 
BMayXXX 
BJunXXX 
BJulXXX 
BAugXXX 
BJanYYY 
BFebYYY 
BMarYYY 
BAprYYY 
BMayYYY 
BJunYYY 
BJulYYY 
BAugYYY 
BJanZZZ 
BFebZZZ 
BMarZZZ 
BAprZZZ 
BMayZZZ 
BJunZZZ 
BJulZZZ 
BAugZZZ 
CJanXXX 
CFebXXX 
CMarXXX 
CAprXXX 
CMayXXX 
CJunXXX 
CJulXXX 
CAugXXX 
CJanYYY 
CFebYYY 
CMarYYY 
CAprYYY 
CMayYYY 
CJunYYY 
CJulYYY 
CAugYYY 
CJanZZZ 
CFebZZZ 
CMarZZZ 
CAprZZZ 
CMayZZZ 
CJunZZZ 
CJulZZZ 
CAugZZZ 

 

Thanks in advance....🙏

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@marzeind , Copy this code in blank query in power query(transform data) and check

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jVFNC8IwDP0rY+BtsjZJu+04BQ+C932wg4J4ERFhB/+9abZ2HXgYLM17LH0vSfs+1WmWNk3Dp851DgqUQPCw5jjdb3shQOTS5fqZOGk0ruY9cyiMXFdqxymRGLI+BUZt204mZnHR1uNDqI/ssFIrO02GONmgToycPjLuum7qvFr0UXl8jNska1F0v3PbJVhO5/HleeE6RvExcsLsRGESyHVYEmOMnYIyklUrZVRG+HP+b3QZTc6LExcT5mELu7hA8W9fPurxEZ6liBT9KzDY9LnaZHPx8AM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Product Type" = _t, #"Production Date" = _t, #"Shipping Date" = _t, Manufacturer = _t, #"YearMonth 1" = _t, #"Benefit YearMonth 1" = _t, #"YearMonth 2" = _t, #"Benefit YearMonth 2" = _t, #"YearMonth 3" = _t, #"Benefit YearMonth 3" = _t, #"Split Benefit to Manufacture A" = _t, #"Split Benefit to Manufacture B" = _t, #"Split Benefit to Manufacture C" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Product Type", type text}, {"Production Date", type date}, {"Shipping Date", type date}, {"Manufacturer", type text}, {"YearMonth 1", type date}, {"Benefit YearMonth 1", Int64.Type}, {"YearMonth 2", type date}, {"Benefit YearMonth 2", Int64.Type}, {"YearMonth 3", type date}, {"Benefit YearMonth 3", Int64.Type}, {"Split Benefit to Manufacture A", Percentage.Type}, {"Split Benefit to Manufacture B", type number}, {"Split Benefit to Manufacture C", type number}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"ID", "Product Type", "Production Date", "Shipping Date", "Manufacturer", "Split Benefit to Manufacture A", "Split Benefit to Manufacture B", "Split Benefit to Manufacture C"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Columns", "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Attribute.1", "Attribute.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type1","YearMonth ","",Replacer.ReplaceText,{"Attribute.2"}),
#"Pivoted Column" = Table.Pivot(#"Replaced Value", List.Distinct(#"Replaced Value"[Attribute.1]), "Attribute.1", "Value"),
#"Renamed Columns" = Table.RenameColumns(#"Pivoted Column",{{"Attribute.2", "Month No"}}),
#"Unpivoted Columns1" = Table.UnpivotOtherColumns(#"Renamed Columns", {"ID", "Product Type", "Production Date", "Shipping Date", "Manufacturer", "Month No", "YearMonth", "Benefit"}, "Attribute", "Value"),
#"Split Column by Delimiter1" = Table.SplitColumn(#"Unpivoted Columns1", "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Attribute.1", "Attribute.2"}),
#"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Attribute.1", type text}, {"Attribute.2", type text}}),
#"Renamed Columns1" = Table.RenameColumns(#"Changed Type2",{{"Attribute.2", "New Manufacturer"}, {"Value", "Benefit %"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns1", "Actual Benefit", each [Benefit]*[#"Benefit %"])
in
#"Added Custom"

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@marzeind , Copy this code in blank query in power query(transform data) and check

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jVFNC8IwDP0rY+BtsjZJu+04BQ+C932wg4J4ERFhB/+9abZ2HXgYLM17LH0vSfs+1WmWNk3Dp851DgqUQPCw5jjdb3shQOTS5fqZOGk0ruY9cyiMXFdqxymRGLI+BUZt204mZnHR1uNDqI/ssFIrO02GONmgToycPjLuum7qvFr0UXl8jNska1F0v3PbJVhO5/HleeE6RvExcsLsRGESyHVYEmOMnYIyklUrZVRG+HP+b3QZTc6LExcT5mELu7hA8W9fPurxEZ6liBT9KzDY9LnaZHPx8AM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Product Type" = _t, #"Production Date" = _t, #"Shipping Date" = _t, Manufacturer = _t, #"YearMonth 1" = _t, #"Benefit YearMonth 1" = _t, #"YearMonth 2" = _t, #"Benefit YearMonth 2" = _t, #"YearMonth 3" = _t, #"Benefit YearMonth 3" = _t, #"Split Benefit to Manufacture A" = _t, #"Split Benefit to Manufacture B" = _t, #"Split Benefit to Manufacture C" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Product Type", type text}, {"Production Date", type date}, {"Shipping Date", type date}, {"Manufacturer", type text}, {"YearMonth 1", type date}, {"Benefit YearMonth 1", Int64.Type}, {"YearMonth 2", type date}, {"Benefit YearMonth 2", Int64.Type}, {"YearMonth 3", type date}, {"Benefit YearMonth 3", Int64.Type}, {"Split Benefit to Manufacture A", Percentage.Type}, {"Split Benefit to Manufacture B", type number}, {"Split Benefit to Manufacture C", type number}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"ID", "Product Type", "Production Date", "Shipping Date", "Manufacturer", "Split Benefit to Manufacture A", "Split Benefit to Manufacture B", "Split Benefit to Manufacture C"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Columns", "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Attribute.1", "Attribute.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type1","YearMonth ","",Replacer.ReplaceText,{"Attribute.2"}),
#"Pivoted Column" = Table.Pivot(#"Replaced Value", List.Distinct(#"Replaced Value"[Attribute.1]), "Attribute.1", "Value"),
#"Renamed Columns" = Table.RenameColumns(#"Pivoted Column",{{"Attribute.2", "Month No"}}),
#"Unpivoted Columns1" = Table.UnpivotOtherColumns(#"Renamed Columns", {"ID", "Product Type", "Production Date", "Shipping Date", "Manufacturer", "Month No", "YearMonth", "Benefit"}, "Attribute", "Value"),
#"Split Column by Delimiter1" = Table.SplitColumn(#"Unpivoted Columns1", "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Attribute.1", "Attribute.2"}),
#"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Attribute.1", type text}, {"Attribute.2", type text}}),
#"Renamed Columns1" = Table.RenameColumns(#"Changed Type2",{{"Attribute.2", "New Manufacturer"}, {"Value", "Benefit %"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns1", "Actual Benefit", each [Benefit]*[#"Benefit %"])
in
#"Added Custom"

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

thanks for your help @amitchandak, this solution really fix my problems. thanks a lot...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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