From 66cebc2bc4f3f893453c289e563a47ef7034fed7 Mon Sep 17 00:00:00 2001 From: Mark Stephan Date: Wed, 20 Mar 2024 15:42:14 -0400 Subject: [PATCH] Added additional Fresenius examples --- .../expressions/expression_library.md | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/content/en/docs/PlaidCloud/expressions/expression_library.md b/content/en/docs/PlaidCloud/expressions/expression_library.md index 57a1ce8..0c05f5f 100644 --- a/content/en/docs/PlaidCloud/expressions/expression_library.md +++ b/content/en/docs/PlaidCloud/expressions/expression_library.md @@ -234,7 +234,7 @@ Now that you have located where you want to add an expression, you can use the t |JSON|json_extract_path_text|func.json_extract_path_text(json, key_1, key_2, ...)||Returns JSON object pointed to by path elements. The return value will be a type of text.| |JSON|json_object_keys|func.json_object_keys(json)||Returns set of keys in the JSON object. Only the "outer" object will be displayed.| |Window Functions|avg|func.avg().over(partition_by=field, order_by=field)||This function returns the average of the values in a group. It ignores null values| -|Window Functions|count|func.count().over(partition_by=field, order_by=field)||An aggregate function that returns the number of rows, or the number of non-NULL rows| +|Window Functions|count|func.count().over(partition_by=field, order_by=field)|[See Examples](#count-examples)|An aggregate function that returns the number of rows, or the number of non-NULL rows| |Window Functions|cume_dist|func.cume_dist().over(partition_by=field, order_by=field)||This function calculates the cumulative distribution of a value within a group of values| |Window Functions|dense_rank|func.dense_rank().over(partition_by=field, order_by=field)||The DENSE_RANK() is a window function that assigns a rank to each row within a partition of a result set| |Window Functions|first_value|func.first_value(field).over(partition_by=field, order_by=field)|[See Examples](#first-value-examples)|FIRST_VALUE is a function that returns the first value in an ordered set of values| @@ -246,7 +246,7 @@ Now that you have located where you want to add an expression, you can use the t |Window Functions|percent_rank|func.percent_rank().over(partition_by=field, order_by=field)||The PERCENT_RANK() function evaluates the relative standing of a value within a partition of a result set| |Window Functions|rank|func.rank().over(partition_by=field, order_by=field)||This is a function that assigns a rank to each row within a partition of a result set| |Window Functions|row_number|func.row_number().over(partition_by=field, order_by=field)||This function is used to provide consecutive numbering of the rows in the result by the order selected in the OVER clause for each partition| -|Window Functions|sum|func.sum().over(partition_by=field, order_by=field)||The SUM function adds values. You can add individual values, cell references or ranges or a mix of all three| +|Window Functions|sum|func.sum().over(partition_by=field, order_by=field)|[See Examples](#sum-examples)|The SUM function adds values. You can add individual values, cell references or ranges or a mix of all three| ## Data Types @@ -286,7 +286,6 @@ case( ) ``` - ### A more complex example with multiple conditions This example returns a price based on quantity. "If" the quantity in the order is more than 100, then give the customer the special price. If it doesn't satisfy the first condition, go to the second. If the quantity is greater than 10 (11-100), then give the customer the bulk price. Otherwise give the customer the regular price. @@ -337,6 +336,33 @@ case( else_ = 'none' ) ``` +```python +CASE WHEN "sol_otif_pod_missing" = 1 THEN +'POD is missing.' +ELSE +'POD exists.' +END +``` + +```python +CASE WHEN +SUM("distance_dc_xd") = 0 THEN 0 +ELSE +sum("XD")/sum("distance_dc_xd") +END +``` + +```python +sum(CASE WHEN "dc" = 'ALAB' THEN +("sol_otif_infull" * "sol_otif_pgi_ontime") +ELSE +0.0 +END) / sum(CASE WHEN "dc" = 'ALAB' THEN +1.0 +ELSE +0.000001 +END) +``` @@ -380,6 +406,8 @@ to_char("Sales_Order_w_Status"."WeekName") func.to_char(func.date_trunc('week', get_column(table, 'date_sol_delivery_required')), 'YYYY-MM-DD') func.to_date(get_column(table, 'File Creation Date'), 'YYYYMMDD') + +to_char("date_delivery", 'YYYY-mm-dd') ``` @@ -618,3 +646,18 @@ Adding the expression above to an **Interval** column called 'remaining' would r +## Sum Examples +```python +(sum("sol_otif_infull" * "sol_otif_pgi_ontime")) / (count(*) + 0.000001) + +sum("sol_otif_qty_filled") / (sum("sol_otif_qty_requested") + 0.000001) +``` + + + +## Count Examples +```python +sum("RW")/COUNT(DISTINCT "ship_to_customer") + +(sum("sol_otif_infull" * "sol_otif_pgi_ontime")) / (count(*) + 0.000001) +```