Formula is changing after getting new data?

JamesRo

New Member
Joined
Jun 30, 2022
Messages
23
Office Version
  1. 2021
Platform
  1. Windows
I have the following sheet which looks at another sheet to calculate product usage.

Cell Formulas
RangeFormula
F1:J1F1=IF(Daily_Stock!F$1="","",VLOOKUP($A$1,Daily_Stock!$A$1:$BU$40,COLUMN(),FALSE))
K1:L1K1=IF(Daily_Stock!L$1="","",VLOOKUP($A$1,Daily_Stock!$A$1:$BU$40,COLUMN(),FALSE))
F2:J14F2=IF(Daily_Stock!F$1="","",(IFERROR(VLOOKUP($A2,Daily_Stock!$A$2:$BU$40,COLUMN(),FALSE)-VLOOKUP($A2,Daily_Stock!$A$2:$BU$40,COLUMN()-1,FALSE),"")))
K2:L14K2=IF(Daily_Stock!L$1="","",(IFERROR(VLOOKUP($A2,Daily_Stock!$A$2:$BU$40,COLUMN(),FALSE)-VLOOKUP($A2,Daily_Stock!$A$2:$BU$40,COLUMN()-1,FALSE),"")))
Named Ranges
NameRefers ToCells
Daily_Stock!ExternalData_1=Daily_Stock!$A$1:$K$32F1:L1








The lookup is based on this table:
sss.xlsx
ABCDEFGHIJK
1ProductWed 21 Jun 2023 AMThu 22 Jun 2023 PMFri 23 Jun 2023 AMFri 23 Jun 2023 PMMon 26 Jun 2023 AMMon 26 Jun 2023 PMTue 27 Jun 2023 AMTue 27 Jun 2023 PMWed 28 Jun 2023 AMWed 28 Jun 2023 PM
210mm Bronze19191919191919191919
310mm Float4231818151577
410mm Grey33333333313131313131
510mm Opti22212121212116161616
610mm Satin25252525252525252525
712mm Float101010103333
812mm Opti Satin4444444444
915mm Float11111111101010101010
1015mm Opti7777777777
114mm Bronze Silv25252525252525252525
124mm Float68666666656561616161
134mm Opti14141010101010101010
144mm Silver32292828272726262525
Daily_Stock


This table is generated by getting data from folder of .CSV files, two a day, AM and PM.
The data is simple: product,qty.

What is happening is kind of difficult to describe.
Each time a new .csv is generated the sheets are updated but the formula in the unpopulated columns i.e. column K onwards of Usage sheet gets its formulae changed.
The column letter, e.g. in column K "=IF(Daily_Stock!L$1" has been increased by one along with every other column to the right.
I have tested, re-corrected the formula (should be K in column K and so on), and then added new .csv but the formula changes, cannot work out why...

Any help appreciated.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
I guess that the import process start by inserting a new column in Daily_Stock, then fill this new column with its data.
Can you show the code used for that process?
 
Upvote 0
I have just used Power Query to import the data from a folder: = Folder.Files("\\SERVER\Company Shared Files\Documents\Daily_Stock")
It takes everything that is there...
 
Upvote 0
I am very sorry, but PowerQuery is out of my knowledge.
Can you check if the script adds a new column before copying the data?
 
Upvote 0
I have this query "Sample File", generated when you "Get Data - From File - From Folder"

Source: = Folder.Files("\\SERVER\Company Shared Files\Documents\Daily_Stock")
Navigation: = Source{0}[Content]
Imported CSV: = Csv.Document(Navigation1,[Delimiter=",", Columns=2, Encoding=1252, QuoteStyle=QuoteStyle.None])
Changed Type: = Table.TransformColumnTypes(#"Imported CSV",{{"Column1", type text}, {"Column2", Int64.Type}})

function = (Parameter1 as binary) => let

and Transform Sample File: = Csv.Document(Parameter1,[Delimiter=",", Columns=2, Encoding=1252, QuoteStyle=QuoteStyle.None])


The Daily_Stock query has the following step "Invoke Custom Function 1": = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content]))

Something here of relevance?

If it is something to do with a new .csv being added each time I might try appending the data into a single file somehow...
 
Upvote 0
Found the editor:

let
Source = Folder.Files("\\SERVER\Company Shared Files\Documents\Daily_Stock"),
#"Sorted Rows" = Table.Sort(Source,{{"Date created", Order.Ascending}, {"Date accessed", Order.Ascending}}),
#"Filtered Hidden Files1" = Table.SelectRows(#"Sorted Rows", each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
#"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
#"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File", Table.ColumnNames(#"Transform File"(#"Sample File"))),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Table Column1",{{"Source.Name", type text}, {"Column1", type text}, {"Column2", Int64.Type}}),
#"Extracted Text Before Delimiter" = Table.TransformColumns(#"Changed Type", {{"Source.Name", each Text.BeforeDelimiter(_, ".txt"), type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Extracted Text Before Delimiter",{{"Column1", "Product"}, {"Column2", "Qty"}}),
#"Pivoted Column" = Table.Pivot(#"Renamed Columns", List.Distinct(#"Renamed Columns"[Source.Name]), "Source.Name", "Qty", List.Sum)
in
#"Pivoted Column"
 
Upvote 0
If no one come for a suggestion then you should republish the question under the PowerTools section, and asking how avoiding that a new column is added to the existing table before importing the new data.
Sorry...
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,956
Members
449,096
Latest member
Anshu121

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