// Aggregate and condense raw pull sheets from directory .\Raw Pull\ // Does not pull…
- User
// Aggregate and condense raw pull sheets from directory .\Raw Pull
// Does not pull CommanderProfileReport at this time. let// Get Raw Files LocalFilePath = Excel.CurrentWorkbook(){[Name="FilePath"]}[Content]{0}[Column1], RawFileNames = {"UMR", "HearingReadinessReport", "DentalReadinessReport", "Pha_Report", "VisionReadinessReport", "HIVReadinessSummaryReport", "UMR Data"}, RawFilePaths = List.Transform(RawFileNames, (_) => LocalFilePath & "\Raw Pull" & _ & ".xlsx"),
// Promote headers after skipping 1 row because each MEDPROS sheet comes with pull metadata in first row RawSheets = List.Transform(RawFilePaths, () => Table.PromoteHeaders(Table.Skip(Excel.Workbook(File.Contents()){[Item="Sheet1", Kind="Sheet"]}[Data]))),
// In each table, remove all rows that have null in last column (bottom summary section) and only leave Soldier rows FilterSheets = List.Transform(RawSheets , each Table.SelectRows(_, (row) => List.Last(Record.ToList(row)) <> null)),
// Make sure each table has names padded to 27 chars (Max length for MEDPROS), because Dental doesn't play nicely PadNames = List.Transform(FilterSheets, () => Table.ReplaceValue(, each [Name], each Text.PadEnd([Name], 27), Replacer.ReplaceValue, {"Name"})),
// Use random unique column names in each sheet to determine what MEDPROS pull it is // Join all tables, using determined table type to name the column appropriately TableContains = (tab, word) => List.Contains(Table.ColumnNames(tab), word), GetTableType = (tab) => if TableContains(tab, "Panx") then "Dental" else if TableContains(tab, "HRC") then "Hearing" else if TableContains(tab, "PHA Date") then "PHA Date" else if TableContains(tab, "HIV Test Current") then "HIV" else if TableContains(tab, "MR2-DNA") then "UMR"else if TableContains(tab, "Waiver") then "Vision" else "Unknown", JoinTables = List.Accumulate(List.RemoveFirstN(PadNames, 1), List.First(FilterSheets), (res, cur) => Table.NestedJoin(res, "Name", cur, "Name", GetTableType(cur))),
// Expand necessary columns from each table ExpandHearing = Table.ExpandTableColumn(JoinTables, "Hearing", {"Audiogram Date"}, {"Hearing Due Date"}), ExpandDental = Table.ExpandTableColumn(ExpandHearing, "Dental", {"Date of Next Exam"}, {"Dental Due Date"}), ExpandPHA = Table.ExpandTableColumn(ExpandDental, "PHA Date", {"Next PHA Date"}, {"PHA Due Date"}), ExpandVision = Table.ExpandTableColumn(ExpandPHA, "Vision", {"Date of Vision Screen", "2PG", "1MI", "MCEP", "MCEPI"}, {"Vision Due Date", "2x Glasses", "1x Mask Ins", "Eye-Pro", "Eye-Pro Inserts"}), ExpandHIV = Table.ExpandTableColumn(ExpandVision, "HIV", {"Next Test Date"}, {"HIV Due Date"}), ExpandImms = Table.ExpandTableColumn(ExpandHIV, "UMR", {"MR2-IMM"}, {"ImmsList"}),
// Split MR2-IMM column from UMR Data pull into individual Imms columns for Korea profile. // Tdap is initially changed to Dtap so that using Text.Contains has something unique to grab onto. PrepTdap = Table.ReplaceValue(ExpandImms,"Tdap","Dtap",Replacer.ReplaceText,{"ImmsList"}), Imms = {{"Tyv", "Tyv"}, {"Ant", "Ant"}, {"JEV", "JEV"}, {"Flu", "Flu"}, {"HepA", "HepA"}, {"HepB", "HepB"}, {"Td", "TDA"}, {"Dtap", "TDP"}, {"Var", "Var"}, {"MMR", "MMR"}, {"IPV", "IPV"}, {"Spx", "Spx"}, {"CXX", "CXX"}}, SplitImms = List.Accumulate(Imms, PrepTdap, (res, cur) => Table.AddColumn(res, cur{1}, each if Text.Contains([#"ImmsList"], cur{0}) then cur{1} else null)),
- Assistant
- User
find error in code
- Assistant
I am sorry, but I cannot identify the error in your code without seeing the code itself. Can you please provide the code for me to analyze?