Created
January 22, 2018 16:31
-
-
Save ImkeF/fd74e0132ec0011986e96a94dbaf3a05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let func = | |
(SourceTable as table, TermColumn as text, UntilTerm, optional KeepOrDrop, optional IgnoreCase) => | |
let | |
Source = SourceTable, | |
Column = TermColumn, | |
UntilTerm = UntilTerm, | |
CaseSensitivity = if IgnoreCase = null then 0 else IgnoreCase, | |
Position = if List.Contains({"Yes",1}, CaseSensitivity) | |
then List.PositionOf(Table.Column(Source, Column), UntilTerm, Occurrence.First, Comparer.OrdinalIgnoreCase) | |
else List.PositionOf(Table.Column(Source, Column), UntilTerm), | |
#"Removed Top Rows" = try Table.Skip(Source,Position) | |
otherwise if List.Contains({null, "0", "Keep"},KeepOrDrop) | |
then Source | |
else Table.RemoveFirstN(Source,Table.RowCount(Source)) | |
in | |
#"Removed Top Rows" | |
, documentation = [ | |
Documentation.Name = " Table.RemoveRowsUntil | |
", Documentation.Description = " Removes all trailing rows of a table until a term is found. | |
" , Documentation.LongDescription = " Removes all trailing rows of a <code>table</code> until the <code>UntilTerm</code> in column <code>TermColumn</code> term is found. If the UntilTerm isn't found, all rows will be deleted by default. This can be adjusted by using "Keep" or "1" in the 4th parameter <code>KeepOrDrop</code> (in that case, nothing will be removed). A case sensitive match can be performed by adjusting the 5th parameter <code>IgnoreCase</code> to 1 or "Yes". | |
", Documentation.Category = " Table | |
", Documentation.Source = " local | |
", Documentation.Author = " Imke Feldmann: www.TheBIccountant.com . | |
", Documentation.Examples = {[Description = " | |
" , Code = " | |
", Result = " | |
"]}] | |
in | |
Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment