Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

m code, table.buffer, power bi query editor, advanced editor

let
Source = Folder.Files("C:\Users\yd201\Desktop\Learning Power BI\MDS Files update"),
#"Inserted Text Between Delimiters" = Table.AddColumn(Source, "Date", each Text.BetweenDelimiters([Name], "_", ".", 2, 0), type text),
#"Replaced Value" = Table.ReplaceValue(#"Inserted Text Between Delimiters","_","/",Replacer.ReplaceText,{"Date"}),
#"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"Date", type date}}),
#"Sorted Rows" = Table.Sort(#"Changed Type",{{"Date", Order.Descending}}),
#"Kept First Rows" = Table.FirstN(#"Sorted Rows",2)
in
#"Kept First Rows"

I want to use table.buffer, but I don't understand where I should use.
The folder has 6 excel file for the time being but every week one new excel file be added.
The first 4 columns of every file is static and remaining 35 columns are dynamic (every week one new date column having demand data will be added at last and one old date column from beginning will be removed, remaining columns data will be updated). 

4 Replies

  • dufoq3's avatar
    dufoq3
    Community Champion

    Hi, why do you want to use table.buffer?

    • Anonymous's avatar
      Anonymous
      Not applicable

      I have learned somewhere that combining tables in query editor is = Appending. Now the output of #"Kept First Rows" = Table.FirstN(#"Sorted Rows",2) will be appended after combining (transformation). Before this step I will add a index column where 0= last weel data and 1= current week data (there will be a removed columns step when we click on combining). Indexing is done, so that I can compare between last week and current week data under 4 categories. 
      #"Kept First Rows" = Table.FirstN(#"Sorted Rows",2) After this query too I have to write further lines to modify my data. 
      and remaining things about the question is said in last question.

      So someone said me to use Table.buffer after sorting , so whenever a new table will be added in the folder, I'll have as static table after sorting and giving first two rows as output .

      • dufoq3's avatar
        dufoq3
        Community Champion

        So use table buffer after sorting 😉 Table buffer is only about speeding your query. But sometimes it can make your query slower. Try tu put table buffer after different steps and test it. It is only way.

  • Anonymous's avatar
    Anonymous
    Not applicable

    How can anyone find if using table.buffer is giving wrong or unexpected outpt?