我有一个如下表,我正在尝试创建具有以下条件的
Custom Colom
:
if [Date] < #date(2024, 7, 15) then consider all the Amount for Code (A1,A2,A3, and A4)
if [Date] >= #date(2024, 7, 15) then consider the Amount only C1 and D1
Code Date Amount Expected Amount
A1 15/06/2024 1 1
B1 15/06/2024 2 2
C1 15/06/2024 3 3
D1 15/06/2024 4 4
A1 15/07/2024 5 0
B1 15/07/2024 6 0
C1 15/07/2024 7 7
D1 15/08/2024 8 8
您的要求与您的预期输出不符,但这应该会给您一个想法。
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Code", type text}, {"Date", type date}, {"Amount", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Expected", each if [Date] < #date(2024, 7, 15) and List.Contains({"A1", "B1", "C1", "D1"}, [Code]) then [Amount] else if [Date] >= #date(2024, 7, 15) and List.Contains({"C1", "D1"}, [Code]) then [Amount] else 0)
in
#"Added Custom"