2017-08-22 7 views
0

パワークエリでは、条件に基づいてテーブルをアンピボットしたいと思います: "IP_address"または "Please state"で始まるもの以外のすべてのカラムをアンピボットします。powerqueryの条件付きアンピボット

これは可能ですか?あなたは、数式バーの左にenter image description hereをクリックして、数式バーに表示される内容置き換えることができます

enter image description here

:あなたはこのようなテーブルで起動した場合

答えて

0

は、ここに1つの方法ですこれで:

#"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") 

これを取得するにはここ

enter image description here

私の完全なクエリコード:

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" 

私はちょうど私があなたので、代わりに(小文字のAとの) "ここで、IP_address" の(資本Aで) "IP_Addressは" を使用気づきましたそのために調整する必要があります。