-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfxPathLength.pq
38 lines (37 loc) · 1.25 KB
/
fxPathLength.pq
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
32
33
34
35
36
37
38
// fxPathLength
// --------------------------- Function ------------------------------
let
fxPathLength = (Path as text) as number =>
let
// Split the path by delimiter "|" into a list
PathList = Text.Split(Path, "|"),
// Count the number of items in the list to determine the path length
PathLength = List.Count(PathList)
in
PathLength,
// --------------------------- Documentation segment ------------------------------
documentation = [
Documentation.Name = "fxPathLength",
Documentation.Description = "This function calculates the length of a hierarchical path by counting the number of levels in the path.",
Documentation.Source = "Custom Function",
Documentation.Version = "1.0",
Documentation.Author = "",
Documentation.Examples =
{
[
Description = "Calculate the path length for a given path '1|4'",
Code = "fxPathLength(""1|4"")",
Result = "2"
]
}
]
// --------------------------- Output ----------------------------------------------
in
Value.ReplaceType(
fxPathLength,
Value.ReplaceMetadata(
Value.Type(fxPathLength),
documentation
)
)
// ------------------------------------------------------------------------------------