--
You received this message because you are subscribed to the Google Groups "liam2-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liam2-users...@googlegroups.com.
To post to this group, send email to liam2...@googlegroups.com.
Visit this group at https://groups.google.com/group/liam2-users.
Hello Ingrid,
Sadly, LIAM2 does not support this operation natively (yet). The good news is that you can emulate it relatively easily.
If your list of values (municipality_ids) is short, the simplest is to use an "or" condition:
if(municipality_id == 10 or municipality_id == 13 or municipality_id == 17,
5 * trunc(age / 5),
age)
If it is longer than a few elements or if the list is determined dynamically, using a loop will be more practical:
num_minicipalities: 30
in_mun_list: False
poslist: 0
while poslist < num_municipalities:
in_mun_list: in_mun_list or municipality_id == municipality_ids[poslist]
poslist: poslist + 1
res: if(in_mun_list,
5 * trunc(age / 5),
age)
But it would probably be cleaner to extract a reusable function out of this:
inlist(expr, valuelist):
- invaluelist: False
- poslist: 0
- while poslist < valuelist.__len__() and not all(invaluelist):
- invaluelist: invaluelist or expr == valuelist[poslist]
- poslist: poslist + 1
- return invaluelist
other_func():
- municipality_ids: [10, 20, 30]
- in_mun_list: inlist(municipality_id, municipality_ids)
- res: if(in_mun_list,
5 * trunc(age / 5),
age)
# or even, do everything in a single expression:
- res: if(inlist(municipality_id, [10, 20, 30]),
5 * trunc(age / 5),
age)
Hope it helps,
Gaëtan
--
You received this message because you are subscribed to the Google Groups "liam2-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
liam2-users...@googlegroups.com.
To post to this group, send email to
liam2...@googlegroups.com.
Visit this group at https://groups.google.com/group/liam2-users.