在power query中,我想要基于一个条件取消透视我的表:取消透视所有列,除了那些以"IP_address“或”请陈述您的“开头的列。
这个是可能的吗?
发布于 2017-08-29 07:43:27
这里有一种方法:
如果您从如下所示的表开始:

您可以单击

,并将公式栏中显示的内容替换为以下内容:
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, List.RemoveNulls(List.Generate(
()=>[A=Table.ColumnNames(Source), Index=0],
each [Index] < List.Count([A]),
each [A=[A],Index =[Index]+1],
each if Text.Start([A]{[Index]},10) = "IP_Address" then [A]{[Index]}
else if Text.Start([A]{[Index]},18) = "Please state your" then [A]{[Index]}
else null
)), "Attribute", "Value")要获得以下信息:

下面是我完整的查询代码:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, List.RemoveNulls(List.Generate(
()=>[A=Table.ColumnNames(Source), Index=0],
each [Index] < List.Count([A]),
each [A=[A],Index =[Index]+1],
each if Text.Start([A]{[Index]},10) = "IP_Address" then [A]{[Index]}
else if Text.Start([A]{[Index]},18) = "Please state your" then [A]{[Index]}
else null
)), "Attribute", "Value")
in
#"Unpivoted Other Columns"我刚刚注意到我用的是"IP_Address“(大写为A)而不是"IP_address”(小写为A),所以你需要调整一下。
https://stackoverflow.com/questions/45811819
复制相似问题