Skip to content

Commit fb2d25b

Browse files
committed
Fix case operator example
1 parent acc7c02 commit fb2d25b

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

docs/apl/scalar-functions/conditional-function.mdx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,45 @@ tags:
1010

1111
| **Function Name** | **Description** |
1212
| ----------------- | ------------------------------------------------------------------------------------------------- |
13-
| [case()](<#case()>) | Evaluates a list of predicates and returns the first result expression whose predicate is satisfied. |
14-
| [iff()](<#iff()>) | Evaluates the first argument (the predicate), and returns the value of either the second or third arguments |
13+
| [case()](#case) | Evaluates a list of conditions and returns the first result expression whose condition is satisfied. |
14+
| [iff()](#iff) | Evaluates the first argument (the predicate), and returns the value of either the second or third arguments |
1515

1616
## case()
1717

18-
Evaluates a list of predicates and returns the first result expression whose predicate is satisfied.
18+
Evaluates a list of conditions and returns the first result whose condition is satisfied.
1919

2020
### Arguments
2121

22-
- predicate: An expression that evaluates to a `boolean` value.
23-
- then: An expression that gets evaluated and its value is returned from the function if `predicate` is the first predicate that evaluates to `true.`
24-
- else: An expression that gets evaluated and its value is returned from the function if neither of the `predicate` evaluate to `true.`
22+
- condition: An expression that evaluates to a Boolean.
23+
- result: An expression that Axiom evaluates and returns the value if its condition is the first that evaluates to true.
24+
- nothingMatchedResult: An expression that Axiom evaluates and returns the value if none of the conditional expressions evaluates to true.
2525

2626
### Returns
2727

28-
The value of the first `then` whose `predicate` evaluates to true, or the value of else if neither of the predicates are satisfied.
28+
Axiom returns the value of the first result whose condition evaluates to true. If none of the conditions is satisfied, Axiom returns the value of `nothingMatchedResult`.
2929

3030
### Example
3131

3232
```kusto
33-
case(predicate, then, else, ...)
33+
case(condition1, result1, condition2, result2, condition3, result3, ..., nothingMatchedResult)
3434
```
3535

3636
```kusto
37-
['sample-http-logs']
38-
| extend Category = case(
39-
req_duration_ms < 18,
40-
resp_body_size_bytes >= 18,
41-
resp_header_size_bytes > 35
37+
['sample-http-logs'] |
38+
extend status_human_readable = case(
39+
status_int == 200,
40+
'OK',
41+
status_int == 201,
42+
'Created',
43+
status_int == 301,
44+
'Moved Permanently',
45+
status_int == 500,
46+
'Internal Server Error',
47+
'Other'
4248
)
4349
```
4450

45-
[Run in Playground](https://play.axiom.co/axiom-play-qf1k/explorer?initForm=%7B%22apl%22%3A%22%5B%27sample-http-logs%27%5D%5Cn%7C%20extend%20Category%20%3D%20case%28%5Cn%20%20%20%20req_duration_ms%20%3C%2018%2C%5Cn%20%20%20%20resp_body_size_bytes%20%3E%3D%2018%2C%20%5Cn%20%20%20%20resp_header_size_bytes%20%3E%2035%5Cn%29%22%2C%22queryOptions%22%3A%7B%22quickRange%22%3A%2230d%22%7D%7D)
51+
[Run in Playground](https://play.axiom.co/axiom-play-qf1k/explorer?initForm=%7B%22apl%22%3A%22%5B'sample-http-logs'%5D%5Cn%7C%20extend%20status_code%20%3D%20case(status_int%20%3D%3D%20200%2C%20'OK'%2C%20status_int%20%3D%3D%20201%2C%20'Created'%2C%20status_int%20%3D%3D%20301%2C%20'Moved%20Permanently'%2C%20status_int%20%3D%3D%20500%2C%20'Internal%20Server%20Error'%2C%20'Other')%22%2C%22queryOptions%22%3A%7B%22quickRange%22%3A%2230m%22%7D%7D)
4652

4753
## iff()
4854

0 commit comments

Comments
 (0)