gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,347
- Office Version
- 365
- Platform
- Windows
I thought that the below was the correct formula but I am getting an error. I thought this checks and if there wasnt already a column named "F. > 1 Year" that it would add it and if there was one it would just go to the next step
= try Table.AddColumn(#"Pivoted Column", "F. > 1 Year", each null, Int64.Type) otherwise #"Pivoted Column"
let
Source = Table.NestedJoin(PBoM_UTable, {"Part Number"}, #"ModelPropricer vdataNISMaterialCostSource", {"PartNumber"}, "ModelPropricer vdataNISMaterialCostSource", JoinKind.LeftOuter),
#"Filtered Rows" = Table.SelectRows(Source, each ([#"Make/Buy"] = "Buy")),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Level", "Type", "Assembly", "Make/Buy", "Qty Per", "Resource", "Curve"}),
#"Expanded ModelPropricer vdataNISMaterialCostSource" = Table.ExpandTableColumn(#"Removed Columns", "ModelPropricer vdataNISMaterialCostSource", {"Category", "Subcategory", "FromQty", "ToQty", "MinBuyQty", "UnitCost", "EXCESS", "NRE", "TARIFF", "StartDate", "EndDate", "Aged", "VendorName", "LeadTime", "MaterialCostSourceComments", "VendorQuoteNumber", "Created by", "Source Id", "Revision Id", "HyperLink", "Commodity", "EscalationID"}, {"Category", "Subcategory", "FromQty", "ToQty", "MinBuyQty", "UnitCost", "EXCESS", "NRE", "TARIFF", "StartDate", "EndDate", "Aged", "VendorName", "LeadTime", "MaterialCostSourceComments", "VendorQuoteNumber", "Created by", "Source Id", "Revision Id", "HyperLink", "Commodity", "EscalationID"}),
#"Merged Queries" = Table.NestedJoin(#"Expanded ModelPropricer vdataNISMaterialCostSource", {"Part Number"}, #"RFQ Tracker Count", {"Part Number"}, "RFQ Tracker Count", JoinKind.LeftOuter),
#"Expanded RFQ Tracker Count" = Table.ExpandTableColumn(#"Merged Queries", "RFQ Tracker Count", {"RFQ Count", "RFQs Rcvd", "NoBidCount", "RFQs SentOut"}, {"RFQ Count", "RFQs Rcvd", "NoBidCount", "RFQs SentOut"}),
#"Merged Queries2" = Table.NestedJoin(#"Expanded RFQ Tracker Count", {"Part Number", "EndItem"}, BEQ_Qtys, {"Part Number", "EndItem"}, "BEQ_Qtys", JoinKind.LeftOuter),
#"Expanded BEQ_Qtys" = Table.ExpandTableColumn(#"Merged Queries2", "BEQ_Qtys", {"Ext BEQ Qty"}, {"Ext BEQ Qty"}),
#"Merged Queries3" = Table.NestedJoin(#"Expanded BEQ_Qtys", {"EndItem", "Part Number", "Source Id", "Revision Id", "FromQty", "ToQty", "MinBuyQty", "UnitCost", "EXCESS", "NRE", "TARIFF"}, Closest2BEQ, {"EndItem", "Part Number", "Source Id", "Revision Id", "FromQty", "ToQty", "MinBuyQty", "UnitCost", "EXCESS", "NRE", "TARIFF"}, "Closest2BEQ", JoinKind.LeftOuter),
#"Expanded Closest2BEQ" = Table.ExpandTableColumn(#"Merged Queries3", "Closest2BEQ", {"Closest BEQ Qty"}, {"Closest BEQ Qty"}),
#"Removed Duplicates" = Table.Distinct(#"Expanded Closest2BEQ", {"EndItem", "Part Number", "Category", "Subcategory", "Source Id"}),
#"Grouped Rows" = Table.Group(#"Removed Duplicates", {"EndItem", "Part Number", "Category"}, {{"Count", each Table.RowCount(_), Int64.Type}, {"ALL", each _, type table [EndItem=text, Part Number=text, Part Description=any, Using SimilarTo 4 Part Number=any, Category=nullable text, Subcategory=nullable text, FromQty=nullable number, ToQty=nullable number, MinBuyQty=nullable number, UnitCost=nullable number, EXCESS=nullable number, NRE=nullable number, TARIFF=nullable number, StartDate=nullable date, EndDate=nullable date, Aged=nullable text, VendorName=nullable text, LeadTime=nullable number, MaterialCostSourceComments=nullable text, VendorQuoteNumber=nullable text, Created by=nullable text, Source Id=nullable text, Revision Id=nullable text, HyperLink=nullable text, Commodity=nullable text, EscalationID=nullable text, RFQ Count=nullable number, RFQs Rcvd=nullable number, NoBidCount=nullable number, RFQs SentOut=nullable number, Ext BEQ Qty=nullable number, Closest BEQ Qty=nullable text]}}),
#"Expanded ALL" = Table.ExpandTableColumn(#"Grouped Rows", "ALL", {"Using SimilarTo 4 Part Number", "Aged", "RFQ Count", "RFQs Rcvd", "NoBidCount", "RFQs SentOut"}, {"Using SimilarTo 4 Part Number", "Aged", "RFQ Count", "RFQs Rcvd", "NoBidCount", "RFQs SentOut"}),
#"Added Custom" = Table.AddColumn(#"Expanded ALL", "Value", each 1),
#"Filtered Rows1" = Table.SelectRows(#"Added Custom", each ([Category] = "Quote")),
#"Pivoted Column" = Table.Pivot(#"Filtered Rows1", List.Distinct(#"Filtered Rows1"[Aged]), "Aged", "Value", List.Sum),
#"Added Custom1" = try Table.AddColumn(#"Pivoted Column", "F. > 1 Year", each null, Int64.Type) otherwise #"Pivoted Column"
in
#"Added Custom1"
= try Table.AddColumn(#"Pivoted Column", "F. > 1 Year", each null, Int64.Type) otherwise #"Pivoted Column"
let
Source = Table.NestedJoin(PBoM_UTable, {"Part Number"}, #"ModelPropricer vdataNISMaterialCostSource", {"PartNumber"}, "ModelPropricer vdataNISMaterialCostSource", JoinKind.LeftOuter),
#"Filtered Rows" = Table.SelectRows(Source, each ([#"Make/Buy"] = "Buy")),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Level", "Type", "Assembly", "Make/Buy", "Qty Per", "Resource", "Curve"}),
#"Expanded ModelPropricer vdataNISMaterialCostSource" = Table.ExpandTableColumn(#"Removed Columns", "ModelPropricer vdataNISMaterialCostSource", {"Category", "Subcategory", "FromQty", "ToQty", "MinBuyQty", "UnitCost", "EXCESS", "NRE", "TARIFF", "StartDate", "EndDate", "Aged", "VendorName", "LeadTime", "MaterialCostSourceComments", "VendorQuoteNumber", "Created by", "Source Id", "Revision Id", "HyperLink", "Commodity", "EscalationID"}, {"Category", "Subcategory", "FromQty", "ToQty", "MinBuyQty", "UnitCost", "EXCESS", "NRE", "TARIFF", "StartDate", "EndDate", "Aged", "VendorName", "LeadTime", "MaterialCostSourceComments", "VendorQuoteNumber", "Created by", "Source Id", "Revision Id", "HyperLink", "Commodity", "EscalationID"}),
#"Merged Queries" = Table.NestedJoin(#"Expanded ModelPropricer vdataNISMaterialCostSource", {"Part Number"}, #"RFQ Tracker Count", {"Part Number"}, "RFQ Tracker Count", JoinKind.LeftOuter),
#"Expanded RFQ Tracker Count" = Table.ExpandTableColumn(#"Merged Queries", "RFQ Tracker Count", {"RFQ Count", "RFQs Rcvd", "NoBidCount", "RFQs SentOut"}, {"RFQ Count", "RFQs Rcvd", "NoBidCount", "RFQs SentOut"}),
#"Merged Queries2" = Table.NestedJoin(#"Expanded RFQ Tracker Count", {"Part Number", "EndItem"}, BEQ_Qtys, {"Part Number", "EndItem"}, "BEQ_Qtys", JoinKind.LeftOuter),
#"Expanded BEQ_Qtys" = Table.ExpandTableColumn(#"Merged Queries2", "BEQ_Qtys", {"Ext BEQ Qty"}, {"Ext BEQ Qty"}),
#"Merged Queries3" = Table.NestedJoin(#"Expanded BEQ_Qtys", {"EndItem", "Part Number", "Source Id", "Revision Id", "FromQty", "ToQty", "MinBuyQty", "UnitCost", "EXCESS", "NRE", "TARIFF"}, Closest2BEQ, {"EndItem", "Part Number", "Source Id", "Revision Id", "FromQty", "ToQty", "MinBuyQty", "UnitCost", "EXCESS", "NRE", "TARIFF"}, "Closest2BEQ", JoinKind.LeftOuter),
#"Expanded Closest2BEQ" = Table.ExpandTableColumn(#"Merged Queries3", "Closest2BEQ", {"Closest BEQ Qty"}, {"Closest BEQ Qty"}),
#"Removed Duplicates" = Table.Distinct(#"Expanded Closest2BEQ", {"EndItem", "Part Number", "Category", "Subcategory", "Source Id"}),
#"Grouped Rows" = Table.Group(#"Removed Duplicates", {"EndItem", "Part Number", "Category"}, {{"Count", each Table.RowCount(_), Int64.Type}, {"ALL", each _, type table [EndItem=text, Part Number=text, Part Description=any, Using SimilarTo 4 Part Number=any, Category=nullable text, Subcategory=nullable text, FromQty=nullable number, ToQty=nullable number, MinBuyQty=nullable number, UnitCost=nullable number, EXCESS=nullable number, NRE=nullable number, TARIFF=nullable number, StartDate=nullable date, EndDate=nullable date, Aged=nullable text, VendorName=nullable text, LeadTime=nullable number, MaterialCostSourceComments=nullable text, VendorQuoteNumber=nullable text, Created by=nullable text, Source Id=nullable text, Revision Id=nullable text, HyperLink=nullable text, Commodity=nullable text, EscalationID=nullable text, RFQ Count=nullable number, RFQs Rcvd=nullable number, NoBidCount=nullable number, RFQs SentOut=nullable number, Ext BEQ Qty=nullable number, Closest BEQ Qty=nullable text]}}),
#"Expanded ALL" = Table.ExpandTableColumn(#"Grouped Rows", "ALL", {"Using SimilarTo 4 Part Number", "Aged", "RFQ Count", "RFQs Rcvd", "NoBidCount", "RFQs SentOut"}, {"Using SimilarTo 4 Part Number", "Aged", "RFQ Count", "RFQs Rcvd", "NoBidCount", "RFQs SentOut"}),
#"Added Custom" = Table.AddColumn(#"Expanded ALL", "Value", each 1),
#"Filtered Rows1" = Table.SelectRows(#"Added Custom", each ([Category] = "Quote")),
#"Pivoted Column" = Table.Pivot(#"Filtered Rows1", List.Distinct(#"Filtered Rows1"[Aged]), "Aged", "Value", List.Sum),
#"Added Custom1" = try Table.AddColumn(#"Pivoted Column", "F. > 1 Year", each null, Int64.Type) otherwise #"Pivoted Column"
in
#"Added Custom1"