0
我有以下Excel 2016 Power Query(獲取&變換查詢)。它工作正常,但我想使用的字段名變量在兩個SelectRows線:嘗試在Excel Power Query SelectRows行中使用變量作爲字段名稱時出錯
let
//Variables:
//Server Name:
DefnameServerName = Excel.CurrentWorkbook(){[Name="IMPORT_SERVER_NAME"]}[Content],
ServerName = DefnameServerName{0}[Column1],
//Database Name:
DefnameDatabaseName = Excel.CurrentWorkbook(){[Name="IMPORT_DATABASE_NAME"]}[Content],
DatabaseName = DefnameDatabaseName{0}[Column1],
//Schema Name:
DefnameSchemaName = Excel.CurrentWorkbook(){[Name="IMPORT_SCHEMA_NAME"]}[Content],
SchemaName = DefnameSchemaName{0}[Column1],
//Table Name:
DefnameTableName = Excel.CurrentWorkbook(){[Name="IMPORT_TABLE_NAME"]}[Content],
TableName = DefnameTableName{0}[Column1],
//ID Field Name:
DefnameFieldNameID = Excel.CurrentWorkbook(){[Name="IMPORT_FIELDNAME_ID"]}[Content],
FieldNameID = DefnameFieldNameID{0}[Column1],
//Customer Field Name:
DefnameFieldNameCustomer = Excel.CurrentWorkbook(){[Name="IMPORT_FIELDNAME_CUSTOMER"]}[Content],
FieldNameCustomer = DefnameFieldNameCustomer{0}[Column1],
//Region Field Name:
DefnameFieldNameRegion = Excel.CurrentWorkbook(){[Name="IMPORT_FIELDNAME_REGION"]}[Content],
FieldNameRegion = DefnameFieldNameRegion{0}[Column1],
//Month Field Name:
DefnameFieldNameMonth = Excel.CurrentWorkbook(){[Name="IMPORT_FIELDNAME_MONTH"]}[Content],
FieldNameMonth = DefnameFieldNameMonth{0}[Column1],
//Forecast Value Field Name:
DefnameFieldNameForecastValue = Excel.CurrentWorkbook(){[Name="IMPORT_FIELDNAME_FORECAST_VALUE"]}[Content],
FieldNameForecastValue = DefnameFieldNameForecastValue{0}[Column1],
//Parameters:
//ID:
DefnameParameterID = Excel.CurrentWorkbook(){[Name="IMPORT_PARAMETER_ID"]}[Content],
ParameterID = DefnameParameterID{0}[Column1],
//Customer:
DefnameParameterCustomer = Excel.CurrentWorkbook(){[Name="IMPORT_PARAMETER_CUSTOMER"]}[Content],
ParameterCustomer = DefnameParameterCustomer{0}[Column1],
Source = Sql.Database(ServerName, DatabaseName),
dbo_MidtermOmnibusForecast = Source{[Schema=SchemaName,Item=TableName]}[Data],
RemoveOtherColumns = Table.SelectColumns(dbo_MidtermOmnibusForecast,{FieldNameID, FieldNameCustomer, FieldNameMonth, FieldNameForecastValue, FieldNameRegion}),
FilterByUUID = Table.SelectRows(RemoveOtherColumns, each ([UUID] = ParameterID)),
FilterByCustomer = Table.SelectRows(FilterByUUID, each ([ForecastName] = ParameterCustomer)),
PivotMonths = Table.Pivot(Table.TransformColumnTypes(FilterByCustomer, {{FieldNameMonth, type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(FilterByCustomer, {{FieldNameMonth, type text}}, "en-US")[ForecastDate]), FieldNameMonth, FieldNameForecastValue, List.Sum),
SortByCustomerThenRegion = Table.Sort(PivotMonths,{{FieldNameCustomer, Order.Ascending}, {FieldNameRegion, Order.Ascending}})
in
SortByCustomerThenRegion
我已經試過這樣:
FilterByUUID = Table.SelectRows(RemoveOtherColumns, each ([FieldNameID] = ParameterID)),
FilterByCustomer = Table.SelectRows(FilterByUUID, each ([FieldNameCustomer] = ParameterCustomer)),
我已經試過這樣:
FilterByUUID = Table.SelectRows(RemoveOtherColumns, each (FieldNameID = ParameterID)),
FilterByCustomer = Table.SelectRows(FilterByUUID, each (FieldNameCustomer = ParameterCustomer)),
但他們都打破查詢。我需要做什麼才能在兩個SelectRows行中使用字段名稱的變量?