在 Power Query 中获取多个日期范围(和 if 语句)内的输出
Get output within multiple date ranges (and if statements) in Power Query
编辑以包含 Power Query 中添加列函数的完整代码。 "Removed Columns1"参考上一步,将自定义列命名为Price。
我正在尝试在 Power Query 中添加自定义列以输出特定日期范围内的价格。尝试了以下 M 代码,但我得到了一个错误:
= Table.AddColumn(#"Removed Columns1", "Price", each
if [Date]<#date(08,12,2019) then "11.50"
else if [Date]>#date(08,11,2019) and [Date]<#date(10,14,2019) then "0.00"
else if [Date]>#date(10,13,2019) and [Date]<#date(12,30,2019) then "11.50"
else "2.50")
我返回的错误:
Expression.Error: The Date operation failed because the resulting value falls outside the range of allowed values.
使用 #date(2019,08,11)
而不是 #date(8/11/2019)
:
= Table.AddColumn(#"Removed Columns1", "Price", each
if [Date]<#date(2019,8,12) then "11.50"
else if [Date]>#date(2019,8,11) and [Date]<#date(2019,10,14) then "0.00"
else if [Date]>#date(2019,10,13) and [Date]<#date(2019,12,30) then "11.50"
else "2.50"
)
编辑以包含 Power Query 中添加列函数的完整代码。 "Removed Columns1"参考上一步,将自定义列命名为Price。
我正在尝试在 Power Query 中添加自定义列以输出特定日期范围内的价格。尝试了以下 M 代码,但我得到了一个错误:
= Table.AddColumn(#"Removed Columns1", "Price", each
if [Date]<#date(08,12,2019) then "11.50"
else if [Date]>#date(08,11,2019) and [Date]<#date(10,14,2019) then "0.00"
else if [Date]>#date(10,13,2019) and [Date]<#date(12,30,2019) then "11.50"
else "2.50")
我返回的错误:
Expression.Error: The Date operation failed because the resulting value falls outside the range of allowed values.
使用 #date(2019,08,11)
而不是 #date(8/11/2019)
:
= Table.AddColumn(#"Removed Columns1", "Price", each
if [Date]<#date(2019,8,12) then "11.50"
else if [Date]>#date(2019,8,11) and [Date]<#date(2019,10,14) then "0.00"
else if [Date]>#date(2019,10,13) and [Date]<#date(2019,12,30) then "11.50"
else "2.50"
)