diff --git a/pykusto/functions.py b/pykusto/functions.py
index 8450ef8..210958f 100644
--- a/pykusto/functions.py
+++ b/pykusto/functions.py
@@ -120,6 +120,8 @@ def ceiling(expr: NumberType) -> NumberExpression:
 
 def cos(expr: NumberType) -> NumberExpression:
     return expr.cos()
+
+
 #
 # def cot(self): return
 
@@ -257,12 +259,12 @@ def hourofday(expr: DatetimeType) -> NumberExpression:
     return expr.hourofday()
 
 
-def iif(predicate: BooleanType, if_true: ExpressionType, if_false: ExpressionType) -> BaseExpression:
-    return BaseExpression(KQL('iif({}, {}, {})'.format(predicate, if_true, if_false)))
+def iff(predicate: BooleanType, if_true: ExpressionType, if_false: ExpressionType) -> BaseExpression:
+    return BaseExpression(KQL('iff({}, {}, {})'.format(predicate, _subexpr_to_kql(if_true), _subexpr_to_kql(if_false))))
 
 
-def iff(predicate: BooleanType, if_true: ExpressionType, if_false: ExpressionType) -> BaseExpression:
-    return BaseExpression(KQL('iff({}, {}, {})'.format(predicate, if_true, if_false)))
+def iif(predicate: BooleanType, if_true: ExpressionType, if_false: ExpressionType) -> BaseExpression:
+    return iff(predicate, if_true, if_false)
 
 
 #
diff --git a/setup.py b/setup.py
index 605de64..b31e771 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
 
 setup(
     name='pykusto',
-    version='0.0.4',
+    version='0.0.5',
     packages=find_packages(exclude=['test']),
     url='https://github.com/Azure/pykusto',
     license='MIT License',

iff doesn't support sub expressions
The following syntax is not working:
.extend(timeDelta=iff(col.day-col.day1 == 0, timedelta(DAYS_BACK_DIFF), col.day-col.day1))
diff --git a/test/test_functions.py b/test/test_functions.py
index 247142d..55fc998 100644
--- a/test/test_functions.py
+++ b/test/test_functions.py
@@ -7,7 +7,7 @@ from pykusto.query import Query
 from test.test_base import TestBase
 
 
-# TODO dcount_hll, iif
+# TODO dcount_hll
 
 class TestFunction(TestBase):
     def test_acos(self):
@@ -629,3 +629,16 @@ class TestFunction(TestBase):
             " | summarize active_days = dcount(bin(timestamp, time(1.0:0:0.0)))",
             Query().summarize(active_days=f.dcount(f.bin(col.timestamp, datetime.timedelta(1)))).render()
         )
+
+    def test_iff(self):
+        self.assertEqual(
+            " | project foo = (iff(foo > (ago(time(2.0:0:0.0))), time(3.0:0:0.0), time(4.0:0:0.0)))",
+            Query().project(foo=f.iff(col.foo > f.ago(datetime.timedelta(2)), datetime.timedelta(3), datetime.timedelta(4))).render()
+        )
+
+    def test_iif(self):
+        # iif is just an alias to iff
+        self.assertEqual(
+            " | project foo = (iff(foo > (ago(time(2.0:0:0.0))), time(3.0:0:0.0), time(4.0:0:0.0)))",
+            Query().project(foo=f.iif(col.foo > f.ago(datetime.timedelta(2)), datetime.timedelta(3), datetime.timedelta(4))).render()
+        )

pip install -e .
parse_log_pytest
pytest
pytest
3.7
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
adal==1.2.7
attrs @ file:///croot/attrs_1668696182826/work
azure-kusto-data==0.0.36
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
cryptography==44.0.2
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
idna==3.10
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1648562407465/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
packaging @ file:///croot/packaging_1671697413597/work
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pycparser==2.21
PyJWT==2.8.0
-e git+https://github.com/Azure/pykusto.git@a6f85c8015b59226608bafa1d2f5d862d1917ef4#egg=pykusto
pytest==7.1.2
python-dateutil==2.9.0.post0
requests==2.31.0
six==1.17.0
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
typing_extensions @ file:///croot/typing_extensions_1669924550328/work
urllib3==2.0.7
zipp @ file:///croot/zipp_1672387121353/work

name: pykusto
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=22.1.0=py37h06a4308_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - flit-core=3.6.0=pyhd3eb1b0_0
  - importlib-metadata=4.11.3=py37h06a4308_0
  - importlib_metadata=4.11.3=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=22.0=py37h06a4308_0
  - pip=22.3.1=py37h06a4308_0
  - pluggy=1.0.0=py37h06a4308_1
  - py=1.11.0=pyhd3eb1b0_0
  - pytest=7.1.2=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py37h06a4308_0
  - typing_extensions=4.4.0=py37h06a4308_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.11.0=py37h06a4308_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - adal==1.2.7
      - azure-kusto-data==0.0.36
      - cffi==1.15.1
      - charset-normalizer==3.4.1
      - cryptography==44.0.2
      - idna==3.10
      - pycparser==2.21
      - pyjwt==2.8.0
      - python-dateutil==2.9.0.post0
      - requests==2.31.0
      - six==1.17.0
      - urllib3==2.0.7
prefix: /opt/conda/envs/pykusto

test/test_functions.py::TestFunction::test_iff test/test_functions.py::TestFunction::test_iif
test/test_functions.py::TestFunction::test_acos test/test_functions.py::TestFunction::test_ago test/test_functions.py::TestFunction::test_any test/test_functions.py::TestFunction::test_arg_max test/test_functions.py::TestFunction::test_arg_min test/test_functions.py::TestFunction::test_array_length test/test_functions.py::TestFunction::test_avgif test/test_functions.py::TestFunction::test_bag_keys test/test_functions.py::TestFunction::test_bin test/test_functions.py::TestFunction::test_bin_at test/test_functions.py::TestFunction::test_bin_auto test/test_functions.py::TestFunction::test_case test/test_functions.py::TestFunction::test_ceiling test/test_functions.py::TestFunction::test_cos test/test_functions.py::TestFunction::test_count test/test_functions.py::TestFunction::test_countif test/test_functions.py::TestFunction::test_dcount test/test_functions.py::TestFunction::test_endofday test/test_functions.py::TestFunction::test_endofmonth test/test_functions.py::TestFunction::test_endofweek test/test_functions.py::TestFunction::test_exp test/test_functions.py::TestFunction::test_exp10 test/test_functions.py::TestFunction::test_exp2 test/test_functions.py::TestFunction::test_floor test/test_functions.py::TestFunction::test_format_datetime test/test_functions.py::TestFunction::test_format_timespan test/test_functions.py::TestFunction::test_getmonth test/test_functions.py::TestFunction::test_gettype test/test_functions.py::TestFunction::test_getyear test/test_functions.py::TestFunction::test_hash test/test_functions.py::TestFunction::test_hash_sha256 test/test_functions.py::TestFunction::test_hourofday test/test_functions.py::TestFunction::test_isempty test/test_functions.py::TestFunction::test_isfinite test/test_functions.py::TestFunction::test_isinf test/test_functions.py::TestFunction::test_isnan test/test_functions.py::TestFunction::test_isnotempty test/test_functions.py::TestFunction::test_isnotnull test/test_functions.py::TestFunction::test_isnull test/test_functions.py::TestFunction::test_isutf8 test/test_functions.py::TestFunction::test_log test/test_functions.py::TestFunction::test_log10 test/test_functions.py::TestFunction::test_log2 test/test_functions.py::TestFunction::test_loggamma test/test_functions.py::TestFunction::test_make_bag test/test_functions.py::TestFunction::test_make_datetime test/test_functions.py::TestFunction::test_make_list test/test_functions.py::TestFunction::test_make_set test/test_functions.py::TestFunction::test_max test/test_functions.py::TestFunction::test_min test/test_functions.py::TestFunction::test_nesting test/test_functions.py::TestFunction::test_now test/test_functions.py::TestFunction::test_percentile test/test_functions.py::TestFunction::test_percentiles test/test_functions.py::TestFunction::test_pow test/test_functions.py::TestFunction::test_round test/test_functions.py::TestFunction::test_sign test/test_functions.py::TestFunction::test_sqrt test/test_functions.py::TestFunction::test_startofday test/test_functions.py::TestFunction::test_startofmonth test/test_functions.py::TestFunction::test_startofweek test/test_functions.py::TestFunction::test_startofyear test/test_functions.py::TestFunction::test_stdev test/test_functions.py::TestFunction::test_stdevif test/test_functions.py::TestFunction::test_stdevp test/test_functions.py::TestFunction::test_strcat test/test_functions.py::TestFunction::test_strcat_array test/test_functions.py::TestFunction::test_strcat_delim test/test_functions.py::TestFunction::test_strcmp test/test_functions.py::TestFunction::test_string_size test/test_functions.py::TestFunction::test_strlen test/test_functions.py::TestFunction::test_strrep test/test_functions.py::TestFunction::test_substring test/test_functions.py::TestFunction::test_sum test/test_functions.py::TestFunction::test_sumif test/test_functions.py::TestFunction::test_tobool test/test_functions.py::TestFunction::test_toboolean test/test_functions.py::TestFunction::test_todouble test/test_functions.py::TestFunction::test_variance test/test_functions.py::TestFunction::test_varianceif test/test_functions.py::TestFunction::test_variancep
setup.py pykusto/functions.py
setup.py pykusto/functions.py