寻找DAX陈述式在日期范围之间分配价值

时间:2019-03-29 19:43:54

标签: powerbi dax powerquery

将值在开始日期和结束日期之间平均分配到每日时段中。

enter image description here

使用日期表 TBTR的值在Todays Date-End Date之间平均分配。

有9天(3 / 29-4 / 7),每天的值按天分类为2.91,以便最终可以绘制该时间段的每天2.91。

1 个答案:

答案 0 :(得分:0)

在这里,它将创建多余的行,您可以根据自己的喜好使用这些行:

    let
        Source = Excel.Workbook(File.Contents("C:\...\Test.xlsx"), null, true),
        Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
        #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
        #"Added Custom1" = Table.AddColumn(#"Promoted Headers", "TBTRAverage", each [TBTR] / Duration.Days([End date]-[Todays date])),
        #"Added Custom" = Table.AddColumn(#"Added Custom1", "Date", each let EndThisRow = [End date] in List.Generate(()=>[Todays date], each _ <= EndThisRow , each Date.AddDays( _ , 1))),
        #"Expanded Date" = Table.ExpandListColumn(#"Added Custom", "Date"),
        #"Changed Type" = Table.TransformColumnTypes(#"Expanded Date",{{"Date", type date}})
    in
        #"Changed Type"

结果: enter image description here