I have written a PQ where 2 tables are merged into the main table in order to filter the main table by date and location.
The table I actual load to the data model has this query
I wanted to parameterise the BusDate and Location parts of this so the user had control over the data loaded. The Merge Location part comes form a table that has this code
This works absolutely fine and the speed of load is similar tor slightly faster than the original SQL query i had.
However this only allows the user to select 1 location. In order to allow them to select all location I added a drop down choice that put 100 into the Location_Value and changed the last line to read
This works correctly, but the refresh takes double the time to refresh a single location. I'm new to PQ so can someone explain what I have done wrong as it isn't logical that this query takes longer?
Thanks for any advice
Mike
The table I actual load to the data model has this query
Code:
let Source = Reporting_Plus_Fact,
#"Removed Columns" = Table.RemoveColumns(Source,{"StockQty", "Description", "Weight", "ServiceChargeValue", "TaxAddOnValue", "ModifierNo", "PriceLevel", "IsCondiment", "CompValue", "CompReason", "Reporting_Clerks"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"PluNo", "PLU"}, {"TotalValue", "Line Retail Sale"}, {"AdjustmentsValue", "Line Retail Discount"}, {"TaxNonAddValue", "VATraw"}}),
#"Filtered Rows" = Table.SelectRows(#"Renamed Columns", each ([CorrectionType] = 0)),
#"Merged BusDate" = Table.NestedJoin(#"Filtered Rows",{"BusDateID"},Reporting_BusDates,{"BusDateID"},"NewColumn",JoinKind.Inner),
#"Expanded NewColumn" = Table.ExpandTableColumn(#"Merged BusDate", "NewColumn", {"BusDate"}, {"BusDate"}),
#"Merged Location" = Table.NestedJoin(#"Expanded NewColumn",{"TransID"},Reporting_Transactions_Fact,{"TransID"},"NewColumn",JoinKind.Inner),
#"Expanded NewColumn1" = Table.ExpandTableColumn(#"Merged Location", "NewColumn", {"Location"}, {"Location"}),
#"Merged Time" = Table.NestedJoin(#"Expanded NewColumn1",{"TimeID"},Reporting_Times,{"TimeID"},"NewColumn",JoinKind.Inner),
#"Expanded NewColumn2" = Table.ExpandTableColumn(#"Merged Time", "NewColumn", {"Hour", "Minute"}, {"Hour", "Minute"}),
#"Renamed Date" = Table.RenameColumns(#"Expanded NewColumn2",{{"BusDate", "Transaction Date"}}),
#"Removed Columns1" = Table.RemoveColumns(#"Renamed Date",{"BusDateID", "TimeID", "CorrectionType"}),
#"Changed Type" = Table.TransformColumnTypes(#"Removed Columns1",{{"VATraw", Currency.Type}}),
#"Added VAT" = Table.AddColumn(#"Changed Type", "VAT", each Number.Round([VATraw],3,RoundingMode.AwayFromZero)),
#"Removed VATraw" = Table.RemoveColumns(#"Added VAT",{"VATraw"})
in
#"Removed VATraw"
I wanted to parameterise the BusDate and Location parts of this so the user had control over the data loaded. The Merge Location part comes form a table that has this code
Code:
let // Lines from parameter table
Parameter = Excel.CurrentWorkbook(){[Name="Parameter"]}[Content],
Location_Value = Parameter{0}[Value],
Source = Sql.Databases("tcp:food.pod.uk,1433"),
StockNetPOD_Journal = Source{[Name="StockNetPOD_Journal"]}[Data],
dbo_Reporting_Transactions_Fact = StockNetPOD_Journal{[Schema="dbo",Item="Reporting_Transactions_Fact"]}[Data],
#"Filtered Rows" = Table.SelectRows(dbo_Reporting_Transactions_Fact, each true),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"TransID", "SalesMode", "SalesType", "Location"}),
#"Filtered Rows1" = Table.SelectRows(#"Removed Other Columns", each ([SalesMode] = 0) and ([SalesType] = 0) and [Location] = Location_Value)
in
#"Filtered Rows1"
This works absolutely fine and the speed of load is similar tor slightly faster than the original SQL query i had.
However this only allows the user to select 1 location. In order to allow them to select all location I added a drop down choice that put 100 into the Location_Value and changed the last line to read
Code:
(if Location_Value=100 then [Location]>0 else [Location] = Location_Value))
This works correctly, but the refresh takes double the time to refresh a single location. I'm new to PQ so can someone explain what I have done wrong as it isn't logical that this query takes longer?
Thanks for any advice
Mike