diff --git a/config/Endobest_Dashboard_Config.xlsx b/config/Endobest_Dashboard_Config.xlsx index d146a8f..bfcc72d 100644 Binary files a/config/Endobest_Dashboard_Config.xlsx and b/config/Endobest_Dashboard_Config.xlsx differ diff --git a/eb_dashboard.py b/eb_dashboard.py index 92a1e4b..74d488e 100644 --- a/eb_dashboard.py +++ b/eb_dashboard.py @@ -766,7 +766,7 @@ def _execute_custom_function(function_name, args, output_inclusion): elif function_name == "if_then_else": # Unified conditional function # Syntax: ["operator", arg1, arg2_optional, result_if_true, result_if_false] - # Operators: "is_true", "is_false", "all_true", "any_true", "is_defined", "is_undefined", "all_defined", "==", "!=" + # Operators: "is_true", "is_false", "all_true", "any_true", "is_defined", "is_undefined", "all_defined", "==", "!=", ">", ">=", "<", "<=" # Sentinel propagation: "undefined" (inconnu) > "N/A" (non applicable) > vraie valeur. if not args or len(args) < 4: @@ -935,6 +935,47 @@ def _execute_custom_function(function_name, args, output_inclusion): result_if_true = resolve_value(args[3]) result_if_false = resolve_value(args[4]) + elif operator in (">", ">=", "<", "<="): + if len(args) != 5: + return f"$$$$ Argument Error: {operator} requires 5 arguments" + value1 = resolve_value(args[1]) + value2 = resolve_value(args[2]) + + v1_undef = value1 is None or value1 == "undefined" + v2_undef = value2 is None or value2 == "undefined" + status = dominant_no_value(v1_undef or v2_undef, + value1 == "N/A" or value2 == "N/A") + if status: + return status + + # Si l'un est numérique, tenter de convertir l'autre ; sinon comparer en string + cmp1, cmp2 = value1, value2 + if isinstance(value1, (int, float)) and not isinstance(value2, (int, float)): + try: + cmp2 = float(value2) + except (ValueError, TypeError): + cmp1 = str(value1) + elif isinstance(value2, (int, float)) and not isinstance(value1, (int, float)): + try: + cmp1 = float(value1) + except (ValueError, TypeError): + cmp2 = str(value2) + + try: + if operator == ">": + condition = (cmp1 > cmp2) + elif operator == ">=": + condition = (cmp1 >= cmp2) + elif operator == "<": + condition = (cmp1 < cmp2) + else: + condition = (cmp1 <= cmp2) + except TypeError: + return f"$$$$ Comparison Error: cannot compare {type(cmp1).__name__} and {type(cmp2).__name__}" + + result_if_true = resolve_value(args[3]) + result_if_false = resolve_value(args[4]) + else: return f"$$$$ Unknown Operator: {operator}"