簡體   English   中英

在 power bi 中展開包含列表和日期的列

[英]Expand column which has list and date in power bi

我有一個包含日期和日期列表的列。

在此處輸入圖像描述

在此處輸入圖像描述 我需要擴展該列,以便列表下的日期列表與列中的日期一起擴展。

我使用了下面的代碼並得到了“Expression.Error:我們無法將 List 類型的值轉換為 Table 類型。詳細信息:Value=[List] Type=[Type]”

Table.TransformColumns([Custom],{{[Custom],each if Value.Is(_,type list) then _ else {_}}})

生成列表的代碼

= Table.AddColumn(#"Removed Blank Rows", "New end date", each let StDt = [#"Grant date #(lf)(dd/mm/yyyy)"],

根據您的代碼擴展列表的代碼。

Table.AddColumn(#"Added Custom", "Custom.1", each Table.TransformColumns([New end date]{{[New end date],each if Value.Is(_,type list) then _ else {_}}}))

這會將非列表行轉換為列表,以便顯示箭頭選項

x = Table.TransformColumns(#"PriorStepName", {{"Custom", each if Value.Is(_, type list) then _ else {_} }} )

然后使用列頂部的箭頭展開。 然后改變類型

前圖:

在此處輸入圖像描述

圖片后

在此處輸入圖像描述

完整示例代碼

let Source =  #table({"a"}, {{"10/1/2020"},{"4/1/2020"},{"6/1/2020"},{"1/1/2020"},{"10/4/2020"},{"10/8/2020"}}),
z = {"5/31/2021","5/15/2020","3/14/2019"},
#"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each if [Index]<2 then z else [a], type any),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
// prior is just to set up sample data
x = Table.TransformColumns(#"Removed Other Columns", {{"Custom", each if Value.Is(_, type list) then _ else {_} }} ),
#"Expanded Custom" = Table.ExpandListColumn(x, "Custom"),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", type date}})
in #"Changed Type"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM