ExtractString
EAZYBI Extracts a fragment of a string using a regular expression.
Syntax
ExtractString(String_Expression, Regular_Expression, Numeric_Expression)
Arguments
String_Expression | MDX expression that returns a string that should be parsed using a regular expression. |
|---|---|
Regular_Expression | Regular expression string that should be used to parse the string. |
Numeric_Expression | Optional. An integer that specifies which capturing group of the regular expression to return. A capturing group is a part of the regular expression in parentheses, numbered from left to right. For example, 1 returns the first group and 2 returns the second group. If you omit this argument, the function returns the full string matched by the regular expression. The function always returns a single string. |
Examples
String extraction
The following example will return '2' :
ExtractString('Estimate:5h. Left:2h.', '.*Left:(\d+).*', 1)
It uses a regular expression that will match Left: followed by one or more digits and will return the first matched group, which is (\d+).
Find Sprints by Sprint number
The formula below extracts a number of the sprint if the sprint name contains this pattern Sprint <number>, for example, Sprint 30, D1 Sprint 30, etc. The sprint number is transferred to a numeric value with the function Val and used in comparison to the value 30.
Val( ExtractString([Sprint].CurrentMember.Name, '.*Sprint (\d+)', 1) ) >= 30
See the sample report, the Sprint Gantt chart in our Demo account. The report has a sprint calculated member Sprints 30+ as a selection on Pages. The calculated member Sprints 30+ uses the formula above as a part of the calculation to identify sprints with a number >= 30 that could be used as a sprint selection on Pages.