-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathList.SelectBySuffix.pq
More file actions
32 lines (29 loc) Β· 1.54 KB
/
List.SelectBySuffix.pq
File metadata and controls
32 lines (29 loc) Β· 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
let
// expects a list of pairs of 2 elements, first is the digit, 2nd is the unit
List.SelectBySuffix.Func = ( items as list, unit as text ) as any =>
List.First(
List.Select( items,
(i) => i{1} = unit ), null ){0}?,
List.SelectBySuffix.Type = type function (
items as (type { text }),
unit as text
) as text meta [
Documentation.Name = "List.SelectBySuffix",
Documentation.LongDescription = Text.Combine({
"After calling <code>Splitter.SplitDigitWithSuffix()</code>, this function will choose one item from the pair", "", "#(tab)<b>Example</b>: For the text <code>'2m 3s'</code> find <code>'2'<code> if unit is <code>'m'<code>"
}, "<br>"),
Documentation.Examples = {
[
Description = "Selects the first item in a list that ends with the specified suffix",
Code = Format.DocExpand( "List.SelectBySuffix( { {β2β, βdβ}, {β3β, βhβ} }, βhβ)" ),
Result = Format.DocExpand("3")
],
[
Description = "Selects the first item in a list that ends with the specified suffix",
Code = Format.DocExpand( "List.SelectBySuffix( { {β2β, βdβ}, {β3β, βhβ} }, βdβ)" ),
Result = Format.DocExpand("2")
]
}
]
in
Value.ReplaceType( List.SelectBySuffix.Func, List.SelectBySuffix.Type )