Forum Discussion
non negative values in difference between date columns in PowerQuery
- 9 years ago
You can basically use the same style when addiing column like this:
For Result1:
List.Max({ #duration(0,0,0,0),
List.Min({[Cont Date 1],[Cont Date 2],[Cont Date 3]}) - [Other Date]
})And for Result2:
List.Max({ #duration(0,0,0,0),
List.Min({[Prop Date 1],[Prop Date 2],[Prop Date 3]})-List.Max({[Cont Date 1],[Cont Date 2],[Cont Date 3]})
})You create lists as your "ranges" to choose from and then you can use List.Min or List.Max as the equivalent to MIN or MAX in Excel.
To create a list, you wrap your comma-separated elements into curly brackets: { FirstElement, SecondElement... }
Also you have to format the first 0 as a duration for the formula to work properly.
- 9 years ago
Not so elegant any more then:
= Table.AddColumn(#"Added Custom", "Custom.1", each try if List.Max({null, List.Min({[Prop Date 1],[Prop Date 2],[Prop Date 3]})-List.Max({[Cont Date 1],[Cont Date 2],[Cont Date 3]}) }) > #duration(0,0,0,0) then List.Max({null, List.Min({[Prop Date 1],[Prop Date 2],[Prop Date 3]})-List.Max({[Cont Date 1],[Cont Date 2],[Cont Date 3]}) }) else 0 otherwise null)
You can basically use the same style when addiing column like this:
For Result1:
List.Max({ #duration(0,0,0,0),
List.Min({[Cont Date 1],[Cont Date 2],[Cont Date 3]}) - [Other Date]
})
And for Result2:
List.Max({ #duration(0,0,0,0),
List.Min({[Prop Date 1],[Prop Date 2],[Prop Date 3]})-List.Max({[Cont Date 1],[Cont Date 2],[Cont Date 3]})
})You create lists as your "ranges" to choose from and then you can use List.Min or List.Max as the equivalent to MIN or MAX in Excel.
To create a list, you wrap your comma-separated elements into curly brackets: { FirstElement, SecondElement... }
Also you have to format the first 0 as a duration for the formula to work properly.
- JohnJairoV9 years agoHelper I
Great ImkeF!
Thanks for your answer. But... If I want to get null results like the example in red, how do you get it? Blessings!
- ImkeF9 years agoCommunity Champion
Not so elegant any more then:
= Table.AddColumn(#"Added Custom", "Custom.1", each try if List.Max({null, List.Min({[Prop Date 1],[Prop Date 2],[Prop Date 3]})-List.Max({[Cont Date 1],[Cont Date 2],[Cont Date 3]}) }) > #duration(0,0,0,0) then List.Max({null, List.Min({[Prop Date 1],[Prop Date 2],[Prop Date 3]})-List.Max({[Cont Date 1],[Cont Date 2],[Cont Date 3]}) }) else 0 otherwise null)