- Posts: 11
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Validate just one array column with min and max value
- lwolters
- Topic Author
- Offline
- New Member
Less
More
3 years 6 months ago #206247
by lwolters
Validate just one array column with min and max value was created by lwolters
Hi,
LimeSurvey: Version 2.06lts Build 160524
I have an array (numbers) with 2 columns (and 14 rows). I want to validate only the second column, coded 'GS'. Values in that column should be between 1 and 19, or empty. I wrote an expression for that and it is working, but I wonder if there is a shorthand using 'self.sq_GS'. I tried, but can't figure it out.
My current expression is:
Thanks in advance!
LimeSurvey: Version 2.06lts Build 160524
I have an array (numbers) with 2 columns (and 14 rows). I want to validate only the second column, coded 'GS'. Values in that column should be between 1 and 19, or empty. I wrote an expression for that and it is working, but I wonder if there is a shorthand using 'self.sq_GS'. I tried, but can't figure it out.
My current expression is:
Code:
(is_empty(Sub_BP_GS.NAOK) OR (Sub_BP_GS.NAOK>0 AND Sub_BP_GS.NAOK<20)) AND (is_empty(Sub_OV_GS.NAOK) OR (Sub_OV_GS.NAOK>0 AND Sub_OV_GS.NAOK<20)) AND (is_empty(Sub_MR_GS.NAOK) OR (Sub_MR_GS.NAOK>0 AND Sub_MR_GS.NAOK<20)) AND (is_empty(Sub_CR_GS.NAOK) OR (Sub_CR_GS.NAOK>0 AND Sub_CR_GS.NAOK<20)) AND (is_empty(Sub_SSC_GS.NAOK) OR (Sub_SSC_GS.NAOK>0 AND Sub_SSC_GS.NAOK<20)) AND (is_empty(Sub_WS_GS.NAOK) OR (Sub_WS_GS.NAOK>0 AND Sub_WS_GS.NAOK<20)) AND (is_empty(Sub_GW_GS.NAOK) OR (Sub_GW_GS.NAOK>0 AND Sub_GW_GS.NAOK<20)) AND (is_empty(Sub_FS_GS.NAOK) OR (Sub_FS_GS.NAOK>0 AND Sub_FS_GS.NAOK<20)) AND (is_empty(Sub_PR_GS.NAOK) OR (Sub_PR_GS.NAOK>0 AND Sub_PR_GS.NAOK<20)) AND (is_empty(Sub_SZ_GS.NAOK) OR (Sub_SZ_GS.NAOK>0 AND Sub_SZ_GS.NAOK<20)) AND (is_empty(Sub_CLN_GS.NAOK) OR (Sub_CLN_GS.NAOK>0 AND Sub_CLN_GS.NAOK<20)) AND (is_empty(Sub_FZ_GS.NAOK) OR (Sub_FZ_GS.NAOK>0 AND Sub_FZ_GS.NAOK<20)) AND (is_empty(Sub_BG_GS.NAOK) OR (Sub_BG_GS.NAOK>0 AND Sub_BG_GS.NAOK<20)) AND (is_empty(Sub_RE_GS.NAOK) OR (Sub_RE_GS.NAOK>0 AND Sub_RE_GS.NAOK<20))
Thanks in advance!
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12944
- Thank you received: 3979
3 years 6 months ago - 3 years 6 months ago #206250
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Validate just one array column with min and max value
Hi,
in these cases I ask "Did you try"?
You know that "self" and "that" are intended for aggregations like count (that.Q1.sq_C1.NAOK), which might be expanded to
count(Q1_SQ001_C1.NAOK,Q1_SQ003_C1.NAOK,Q1_SQ003_C1.NAOK,...)
So if you tried to use is_empty(that.Q1.sq_C1.NAOK) you'd get
is_empty(Q1_SQ001_C1, Q1_SQ002_C1, Q1_SQ003_C1)
You see the algorithm of expanding works fine but leads to wrong syntax of the function "is_empty".
Conclusion: You expression is fine.
Of course you could consider to limit the values of this column by javascript
I saw which version you are using and removed the dropdown image.
Joffm
in these cases I ask "Did you try"?
You know that "self" and "that" are intended for aggregations like count (that.Q1.sq_C1.NAOK), which might be expanded to
count(Q1_SQ001_C1.NAOK,Q1_SQ003_C1.NAOK,Q1_SQ003_C1.NAOK,...)
So if you tried to use is_empty(that.Q1.sq_C1.NAOK) you'd get
is_empty(Q1_SQ001_C1, Q1_SQ002_C1, Q1_SQ003_C1)
You see the algorithm of expanding works fine but leads to wrong syntax of the function "is_empty".
Conclusion: You expression is fine.
Of course you could consider to limit the values of this column by javascript
I saw which version you are using and removed the dropdown image.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 6 months ago by Joffm.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13647
- Thank you received: 2491
3 years 6 months ago #206254
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Validate just one array column with min and max value
Unsure :
sum(
countifop("<",1,self.sq_GS.NAOK),
countifop(">",19,self.sq_GS.NAOK)
) == 0
I'm unsure because of countifop < 1 with "" empty, then maybe:
sum(
countifop("<",1,self.sq_GS.NAOK),
countifop(">",19,self.sq_GS.NAOK),
count(self.sq_GS.NAOK) - 14
) == 0
count(self.sq_GS.NAOK) - 14 is here to reduce by empty value …
sum(
countifop("<",1,self.sq_GS.NAOK),
countifop(">",19,self.sq_GS.NAOK)
) == 0
I'm unsure because of countifop < 1 with "" empty, then maybe:
sum(
countifop("<",1,self.sq_GS.NAOK),
countifop(">",19,self.sq_GS.NAOK),
count(self.sq_GS.NAOK) - 14
) == 0
count(self.sq_GS.NAOK) - 14 is here to reduce by empty value …
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: lwolters, Joffm
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12944
- Thank you received: 3979
3 years 6 months ago #206258
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Validate just one array column with min and max value
Great.
Though I like this function (countifop), it didn't occur to me today.
Joffm
Though I like this function (countifop), it didn't occur to me today.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- lwolters
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
3 years 6 months ago #206263
by lwolters
Replied by lwolters on topic Validate just one array column with min and max value
Hi,
I tested it, and it seems to work well. Thanks a lot!
I tested it, and it seems to work well. Thanks a lot!
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13647
- Thank you received: 2491
3 years 6 months ago #206299
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Validate just one array column with min and max value
What solution exactly work ?
I mean countifop("<",1,self.sq_GS.NAOK), count "empty' value or not ?
I mean countifop("<",1,self.sq_GS.NAOK), count "empty' value or not ?
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12944
- Thank you received: 3979
3 years 6 months ago #206306
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Validate just one array column with min and max value
Hi, @Denis,
the second.
Joffm
the second.
sum(
countifop("<",1,self.sq_GS.NAOK),
countifop(">",19,self.sq_GS.NAOK),
count(self.sq_GS.NAOK) - 14
) == 0
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13647
- Thank you received: 2491
3 years 6 months ago #206307
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Validate just one array column with min and max value
OK then countifop("<",1,self.sq_GS.NAOK) include "" value
Thank you.
Thank you.
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.