Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
MarkDGaal
Helper III
Helper III

How and When to use List & Table Buffer?

Hi all, I have the below query that uses a 15.2MB excel document to provide Fuel Costs. The query also contains two parameters that allow end-users to provide a custom fuel cost per gallon if desired or to apply the appropriate rate of inflation if desired.

 

Because of all the pivoting, merging and re-merging that occurs with the source excel document it seems that PBI actual loads 45.6MB to the data model each time a parameter is changed and the changes are applied to the report. Is Table.Buffer my friend here? If so, how do I use it and is there a nice and easy layman's understanding of when List.Buffer or Table.Buffer is appropriate to use?


Moreover, 5 other queries use this source excel document to query various types of costs..... so as you can imaging having to load somewhere between 15.2MB - 45.6MB per query is taking a little bit of time when something like the inflation parameter effects all queries/tables.

 

let
    Source = #"REF_CPFH_AirOperationsTable (Indexed)",
    #"Filtered Rows" = Table.SelectRows(Source, each ([Column Header Name] = "Fuel Gallons - Commercial" or [Column Header Name] = "Fuel Gallons - DoD")),
    #"Pivoted Column" = Table.Pivot(#"Filtered Rows", List.Distinct(#"Filtered Rows"[#"Column Header Name"]), "Column Header Name", "Value", List.Sum),
    #"Merged Queries2" = Table.NestedJoin(#"Pivoted Column",{"FY", "FHPTAircraftType", "Segment Mission Base of Operation Code", "Mission Base of Operation Branch Code", "Mission Base of Operation Region Code"},#"REF_CPFH_AirOperationsTable (Indexed)",{"FY", "FHPTAircraftType", "Segment Mission Base of Operation Code", "Mission Base of Operation Branch Code", "Mission Base of Operation Region Code"},"NewColumn",JoinKind.LeftOuter),
    #"Expanded NewColumn2" = Table.ExpandTableColumn(#"Merged Queries2", "NewColumn", {"Index", "Column Header Name", "Value"}, {"Index.1", "Column Header Name", "Value"}),
    #"Filtered Rows1" = Table.SelectRows(#"Expanded NewColumn2", each ([Column Header Name] = "Fuel Cost per Gallon - Commercial" or [Column Header Name] = "Fuel Cost per Gallon - DoD")),
    #"CC: Fuel Cost" = Table.AddColumn(#"Filtered Rows1", "Fuel Cost", each if(Fuel_CostPerGallon="Actuals") 
and [Column Header Name]="Fuel Cost per Gallon - Commercial" 
then [#"Fuel Gallons - Commercial"]*[#"Value"]

else if(Fuel_CostPerGallon="Actuals") 
and [Column Header Name]="Fuel Cost per Gallon - DoD" 
then [#"Fuel Gallons - DoD"]*[#"Value"]

else if(Fuel_CostPerGallon<>"Actuals") 
and [Column Header Name]="Fuel Cost per Gallon - Commercial" 
then [#"Fuel Gallons - Commercial"]*Fuel_CostPerGallon

else if(Fuel_CostPerGallon<>"Actuals")
and [Column Header Name]="Fuel Cost per Gallon - DoD" 
then [#"Fuel Gallons - DoD"]*Fuel_CostPerGallon

else "Not Possible"),
    #"Changed Type1" = Table.TransformColumnTypes(#"CC: Fuel Cost",{{"Fuel Cost", type number}}),
    #"Merged Queries1" = Table.NestedJoin(#"Changed Type1",{"Column Header Name"},SRC_Fuel_Hierarchy,{"Column Header Name"},"NewColumn",JoinKind.LeftOuter),
    #"Expanded NewColumn1" = Table.ExpandTableColumn(#"Merged Queries1", "NewColumn", {"AGB Cost Element", "Cost Category"}, {"AGB Cost Element", "Cost Category"}),
    #"Filtered Rows2" = Table.SelectRows(#"Expanded NewColumn1", each ([Fuel Cost] <> null)),
    #"Renamed Columns" = Table.RenameColumns(#"Filtered Rows2",{{"Fuel Cost", "Fuel Cost2"}}),
    #"Merged Queries" = Table.NestedJoin(#"Renamed Columns",{"FY"},SRC_InflationRate_CPI_BLS,{"FY"},"NewColumn",JoinKind.LeftOuter),
    #"Expanded NewColumn" = Table.ExpandTableColumn(#"Merged Queries", "NewColumn", {"Cumulative Inflation by FY to Date"}, {"Cumulative Inflation by FY to Date"}),
    #"Added Custom" = Table.AddColumn(#"Expanded NewColumn", "Fuel Cost", each if(Inflation_BLS_CPI="Yes")
then [Fuel Cost2]+([Fuel Cost2]*([Cumulative Inflation by FY to Date]/100))

else 
[Fuel Cost2]),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Fuel Cost", type number}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Fuel Cost2"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"Index","Index.1", "FY", "FHPTAircraftType", "Segment Mission Base of Operation Code", "Mission Base of Operation Branch Code", "Mission Base of Operation Region Code", "Flight Hours", "Fuel Gallons - Commercial", "Fuel Gallons - DoD", "Column Header Name", "Value", "Fuel Cost", "Cumulative Inflation by FY to Date", "AGB Cost Element", "Cost Category"})
in
    #"Reordered Columns"

 

1 REPLY 1
v-haibl-msft
Microsoft Employee
Microsoft Employee

@MarkDGaal

 

I’m not an advanced Power Query user but I think you can take a look at following two threads which related to Table.Buffer. Maybe it can help you.

http://community.powerbi.com/t5/Desktop/How-to-Improve-Query-Reference-performance-for-large-tables/...

http://community.powerbi.com/t5/Desktop/Queries-over-large-data-tables/m-p/26783/highlight/true#M852...

 

Best Regards,

Herbert

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.