Missy Record from Power Query

jarett

Board Regular
Joined
Apr 12, 2021
Messages
179
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a file folder where I am pulling the value from the same cell in each file, then recording it in the next line/row with the file name on a separate worksheet. I had implemented a filters but can't seem to find why one files value is getting left off (10_5_2023_2), I have another file (09_15_2023_4) with the same value in that cell and it is include in my output file. I tried deleting filtered rows, but can't find which one is affecting that record. The last file in this screenshot is the file I am losing somewhere.
1696622676301.png


This is my file where I am storing the values from each file in a specified folder.
Inventory_Average.xlsx
ABCD
1NameSheets.Data.Column3Inventory Discrepance % AverageGoal = 0%
209_01_2023_1.xlsx25%22.01%Excellent = 0.9%-5%
309_01_2023_9.xlsx9%Good = 5.1%-15%
409_06_2023_1.xlsx17%Average=15.1%-25%
509_06_2023_2.xlsx6%Needs Attention > 25.1%
609_06_2023_3.xlsx18%
709_07_2023_1.xlsx16%
809_07_2023_2.xlsx15%
909_07_2023_3.xlsx5%
1009_08_2023_1.xlsx9%
1109_08_2023_2.xlsx13%
1209_08_2023_3.xlsx10%
1309_08_2023_4.xlsx34%
1409_08_2023_5.xlsx60%
1509_11_2023_1.xlsx30%
1609_12_2023_1.xlsx19%
1709_13_2023_1.xlsx11%
1809_13_2023_2.xlsx12%
1909_15_2023_1.xlsx13%
2009_15_2023_13.xlsx1%
2109_15_2023_14.xlsx39%
2209_15_2023_3.xlsx1%
2309_15_2023_4.xlsx0%
2409_15_2023_5.xlsx57%
2509_15_2023_8.xlsx2%
2609_15_2023_9.xlsx2%
2709_18_2023_1.xlsx23%
2809_18_2023_10.xlsx54%
2909_18_2023_11.xlsx41%
3009_18_2023_12.xlsx5%
3109_18_2023_13.xlsx50%
3209_18_2023_14.xlsx35%
3309_18_2023_15.xlsx9%
3409_18_2023_16.xlsx2%
3509_18_2023_17.xlsx84%
3609_18_2023_18.xlsx50%
3709_18_2023_2.xlsx1%
3809_18_2023_21.xlsx33%
3909_18_2023_23.xlsx58%
4009_18_2023_24.xlsx1%
4109_18_2023_27.xlsx16%
4209_18_2023_28.xlsx31%
4309_18_2023_29.xlsx25%
4409_18_2023_3.xlsx17%
4509_18_2023_30.xlsx55%
4609_18_2023_31.xlsx22%
4709_18_2023_32.xlsx3%
4809_18_2023_4.xlsx17%
4909_18_2023_5.xlsx50%
5009_18_2023_6.xlsx30%
5109_18_2023_8.xlsx25%
5209_19_2023_1.xlsx63%
5309_20_2023_1.xlsx4%
5409_20_2023_3.xlsx6%
5509_20_2023_4.xlsx75%
5609_20_2023_5.xlsx10%
5709_20_2023_6.xlsx1%
5809_20_2023_7.xlsx8%
5909_21_2023_1.xlsx55%
6009_21_2023_11.xlsx20%
6109_21_2023_12.xlsx48%
6209_21_2023_2.xlsx17%
6309_21_2023_3.xlsx2%
6409_21_2023_4.xlsx64%
6509_21_2023_6.xlsx21%
6609_21_2023_7.xlsx12%
6709_21_2023_8.xlsx3%
6809_21_2023_9.xlsx23%
6909_22_2023_1.xlsx8%
7009_25_2023_3.xlsx22%
7109_25_2023_4.xlsx4%
7209_25_2023_5.xlsx19%
7309_25_2023_6.xlsx3%
7409_25_2023_7.xlsx19%
7509_25_2023_8.xlsx2%
7609_26_2023_1.xlsx3%
7709_26_2023_2.xlsx30%
7809_26_2023_3.xlsx23%
7909_26_2023_5.xlsx22%
8009_26_2023_99.xlsx9%
8109_27_2023_2.xlsx29%
8209_27_2023_3.xlsx23%
8309_27_2023_4.xlsx13%
8409_27_2023_5.xlsx19%
8509_28_2023_1.xlsx19%
8609_29_2023_1.xlsx17%
8709_29_2023_2.xlsx21%
8809_29_2023_3.xlsx15%
8910_02_2023_1.xlsx18%
9010_03_2023_1.xlsx9%
9110_03_2023_2.xlsx18%
9210_05_2023_1.xlsx54%
9310_05_2023_12.xlsx16%
Inventory_Discrepance
Cell Formulas
RangeFormula
C2C2=AVERAGEIF(B2:B5090,">0")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C2Cell Valuebetween 0.151 and 0.25textNO
C2Cell Value>0.251textNO
C2Cell Valuebetween 0.051 and 0.15textNO
C2Cell Valuebetween 0.001 and 0.049textNO
C2Cell Value=0textNO


These are my steps in Power Query
Power Query:
let
    Source = Folder.Files("L:\Warehouse and Gen Inventory\Inventory_Discrepance"),
    #"Filtered Rows2" = Table.SelectRows(Source, each not Text.StartsWith([Name], "07")),
    #"Added Custom" = Table.AddColumn(#"Filtered Rows2", "Sheets", each Excel.Workbook(File.Contents([Folder Path]&[Name]))),
    #"Expanded Sheets" = Table.ExpandTableColumn(#"Added Custom", "Sheets", {"Name", "Data", "Item", "Kind", "Hidden"}, {"Sheets.Name", "Sheets.Data", "Sheets.Item", "Sheets.Kind", "Sheets.Hidden"}),
    #"Expanded Sheets.Data" = Table.ExpandTableColumn(#"Expanded Sheets", "Sheets.Data", {"Column3"}, {"Sheets.Data.Column3"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Sheets.Data",{"Content", "Extension", "Date accessed", "Date modified", "Date created", "Attributes", "Folder Path", "Sheets.Item", "Sheets.Kind", "Sheets.Hidden", "Sheets.Name"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each true),
    #"Removed Blank Rows" = Table.SelectRows(#"Filtered Rows", each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null}))),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Blank Rows",{{"Sheets.Data.Column3", type text}}),
    #"Filtered Rows1" = Table.SelectRows(#"Changed Type", each Text.StartsWith([Sheets.Data.Column3], "0.")),
    #"Changed Type1" = Table.TransformColumnTypes(#"Filtered Rows1",{{"Sheets.Data.Column3", Percentage.Type}})
in
    #"Changed Type1"
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
You have the data and the query, so at which step does the information disappear from the results?
 
Upvote 0
You have the data and the query, so at which step does the information disappear from the results?
I figured out it is this step with the filter that is causing the issue,
Power Query:
#"Filtered Rows1" = Table.SelectRows(#"Changed Type", each Text.StartsWith([Sheets.Data.Column3], "0.")),

The step before has the file names listed a bunch of times and the only rows that I want to include contain a number > 0
 
Upvote 0
If it disappears at that point, then whatever row you are expecting to be there does not match your criterion.
 
Upvote 0
If it disappears at that point, then whatever row you are expecting to be there does not match your criterion.
After a little trial and error, I got it to include that record. Had to add some more filters and edit one that was already there.
Power Query:
 #"Filtered Rows3" = Table.SelectRows(#"Changed Type", each [Sheets.Data.Column3] <> "000" or [Sheets.Data.Column3] <> "001" and [Sheets.Data.Column3] <> "002" and [Sheets.Data.Column3] <> "003" and [Sheets.Data.Column3] <> "WarehouseCode"),
    #"Filtered Rows1" = Table.SelectRows(#"Filtered Rows3", each Text.StartsWith([Sheets.Data.Column3], "0")),
    #"Filtered Rows4" = Table.SelectRows(#"Filtered Rows1", each [Sheets.Data.Column3] <> "000" and [Sheets.Data.Column3] <> "001" and [Sheets.Data.Column3] <> "002" and [Sheets.Data.Column3] <> "003" and [Sheets.Data.Column3] <> "009"),
 
Upvote 0
Solution

Forum statistics

Threads
1,224,813
Messages
6,181,112
Members
453,021
Latest member
Justyna P

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