- Posts: 2
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Combine equations & send risk alerts
- mu_akubaraly
- Topic Author
- Offline
- New Member
Less
More
10 months 2 weeks ago #228003
by mu_akubaraly
Combine equations & send risk alerts was created by mu_akubaraly
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
I have 2 equations (which work perfectly) and gives us a % score. I want to combine 2 equations to say if equationA is < 100% AND equationB is < 85% then risky & send out email alerts. I know how to configure the email notifications, I just need to know how to combine these 2 equations into one.
EquationA : {if(100-sum(if(INSERTANS:324926X17X804SQ031=="No",100,0),if(INSERTANS:324926X17X804SQ032=="No",100,0),if(INSERTANS:324926X17X804SQ033=="No",100,0),if(INSERTANS:324926X17X804SQ034=="No",100,0),if(INSERTANS:324926X17X804SQ035=="No",100,0),if(INSERTANS:324926X17X804SQ036=="No",100,0),if(INSERTANS:324926X17X804SQ037=="No",100,0))<100,0,100)}%
EquationB: {if(100-sum(if(INSERTANS:324926X17X804SQ031=="No",100,0),if(INSERTANS:324926X17X804SQ032=="No",100,0),if(INSERTANS:324926X17X804SQ033=="No",100,0),if(INSERTANS:324926X17X804SQ034=="No",100,0),if(INSERTANS:324926X17X804SQ035=="No",100,0),if(INSERTANS:324926X17X804SQ036=="No",100,0),if(INSERTANS:324926X17X804SQ037=="No",100,0))<100,0,round(sum(if(INSERTANS:324926X17X804SQ001=="No",5,0),if(INSERTANS:324926X17X804SQ002=="No",2,0),if(INSERTANS:324926X17X804SQ003=="No",2,0),if(INSERTANS:324926X17X804SQ004=="No",3,0),if(INSERTANS:324926X17X804SQ005!="No",3,0),if(INSERTANS:324926X17X804SQ006=="No",2,0),if(INSERTANS:324926X17X804SQ007=="No",2,0),if(INSERTANS:324926X17X804SQ008=="No",2,0),if(INSERTANS:324926X17X804SQ009=="No",5,0),if(INSERTANS:324926X17X804SQ010=="No",5,0),if(INSERTANS:324926X17X804SQ011=="No",5,0),if(INSERTANS:324926X17X804SQ012=="No",5,0),if(INSERTANS:324926X17X804SQ013=="No",2,0),if(INSERTANS:324926X17X804SQ014=="No",2,0),if(INSERTANS:324926X17X804SQ015=="No",3,0),if(INSERTANS:324926X17X804SQ016=="No",3,0),if(INSERTANS:324926X17X804SQ017=="No",3,0),if(INSERTANS:324926X17X804SQ018=="No",5,0),if(INSERTANS:324926X17X804SQ019!="No",5,0),if(INSERTANS:324926X17X804SQ020=="No",5,0),if(INSERTANS:324926X17X804SQ021=="No",5,0)if(INSERTANS:324926X17X804SQ022=="No",5,0),if(INSERTANS:324926X17X804SQ023=="No",3,0),if(INSERTANS:324926X17X804SQ024=="No",3,0),if(INSERTANS:324926X17X804SQ025=="No",5,0),if(INSERTANS:324926X17X804SQ026=="No",5,0),if(INSERTANS:324926X17X804SQ027=="No",3,0),if(INSERTANS:324926X17X804SQ028=="No",3,0),if(INSERTANS:324926X17X804SQ029=="No",3,0),if(INSERTANS:324926X17X804SQ030=="No",5,0),if(INSERTANS:324926X17X804SQ031=="No",5,0),if(INSERTANS:324926X17X804SQ032=="No",5,0),if(INSERTANS:324926X17X804SQ033=="No",5,0),if(INSERTANS:324926X17X804SQ034=="No",5,0),if(INSERTANS:324926X17X804SQ035=="No",5,0),if(INSERTANS:324926X17X804SQ036=="No",5,0),if(INSERTANS:324926X17X804SQ037=="No",5,0),if(INSERTANS:324926X17X804SQ038=="No",2,0),if(INSERTANS:324926X17X804SQ039=="No",2,0),if(INSERTANS:324926X17X804SQ040=="No",2,0),if(INSERTANS:324926X17X804SQ041=="No",2,0),if(INSERTANS:324926X17X804SQ042=="No",2,0),if(INSERTANS:324926X17X804SQ043=="No",2,0),if(INSERTANS:324926X17X804SQ044=="No",2,0))/158*100,2))}%
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
I have 2 equations (which work perfectly) and gives us a % score. I want to combine 2 equations to say if equationA is < 100% AND equationB is < 85% then risky & send out email alerts. I know how to configure the email notifications, I just need to know how to combine these 2 equations into one.
EquationA : {if(100-sum(if(INSERTANS:324926X17X804SQ031=="No",100,0),if(INSERTANS:324926X17X804SQ032=="No",100,0),if(INSERTANS:324926X17X804SQ033=="No",100,0),if(INSERTANS:324926X17X804SQ034=="No",100,0),if(INSERTANS:324926X17X804SQ035=="No",100,0),if(INSERTANS:324926X17X804SQ036=="No",100,0),if(INSERTANS:324926X17X804SQ037=="No",100,0))<100,0,100)}%
EquationB: {if(100-sum(if(INSERTANS:324926X17X804SQ031=="No",100,0),if(INSERTANS:324926X17X804SQ032=="No",100,0),if(INSERTANS:324926X17X804SQ033=="No",100,0),if(INSERTANS:324926X17X804SQ034=="No",100,0),if(INSERTANS:324926X17X804SQ035=="No",100,0),if(INSERTANS:324926X17X804SQ036=="No",100,0),if(INSERTANS:324926X17X804SQ037=="No",100,0))<100,0,round(sum(if(INSERTANS:324926X17X804SQ001=="No",5,0),if(INSERTANS:324926X17X804SQ002=="No",2,0),if(INSERTANS:324926X17X804SQ003=="No",2,0),if(INSERTANS:324926X17X804SQ004=="No",3,0),if(INSERTANS:324926X17X804SQ005!="No",3,0),if(INSERTANS:324926X17X804SQ006=="No",2,0),if(INSERTANS:324926X17X804SQ007=="No",2,0),if(INSERTANS:324926X17X804SQ008=="No",2,0),if(INSERTANS:324926X17X804SQ009=="No",5,0),if(INSERTANS:324926X17X804SQ010=="No",5,0),if(INSERTANS:324926X17X804SQ011=="No",5,0),if(INSERTANS:324926X17X804SQ012=="No",5,0),if(INSERTANS:324926X17X804SQ013=="No",2,0),if(INSERTANS:324926X17X804SQ014=="No",2,0),if(INSERTANS:324926X17X804SQ015=="No",3,0),if(INSERTANS:324926X17X804SQ016=="No",3,0),if(INSERTANS:324926X17X804SQ017=="No",3,0),if(INSERTANS:324926X17X804SQ018=="No",5,0),if(INSERTANS:324926X17X804SQ019!="No",5,0),if(INSERTANS:324926X17X804SQ020=="No",5,0),if(INSERTANS:324926X17X804SQ021=="No",5,0)if(INSERTANS:324926X17X804SQ022=="No",5,0),if(INSERTANS:324926X17X804SQ023=="No",3,0),if(INSERTANS:324926X17X804SQ024=="No",3,0),if(INSERTANS:324926X17X804SQ025=="No",5,0),if(INSERTANS:324926X17X804SQ026=="No",5,0),if(INSERTANS:324926X17X804SQ027=="No",3,0),if(INSERTANS:324926X17X804SQ028=="No",3,0),if(INSERTANS:324926X17X804SQ029=="No",3,0),if(INSERTANS:324926X17X804SQ030=="No",5,0),if(INSERTANS:324926X17X804SQ031=="No",5,0),if(INSERTANS:324926X17X804SQ032=="No",5,0),if(INSERTANS:324926X17X804SQ033=="No",5,0),if(INSERTANS:324926X17X804SQ034=="No",5,0),if(INSERTANS:324926X17X804SQ035=="No",5,0),if(INSERTANS:324926X17X804SQ036=="No",5,0),if(INSERTANS:324926X17X804SQ037=="No",5,0),if(INSERTANS:324926X17X804SQ038=="No",2,0),if(INSERTANS:324926X17X804SQ039=="No",2,0),if(INSERTANS:324926X17X804SQ040=="No",2,0),if(INSERTANS:324926X17X804SQ041=="No",2,0),if(INSERTANS:324926X17X804SQ042=="No",2,0),if(INSERTANS:324926X17X804SQ043=="No",2,0),if(INSERTANS:324926X17X804SQ044=="No",2,0))/158*100,2))}%
Please Log in to join the conversation.
10 months 2 weeks ago - 10 months 2 weeks ago #228007
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Combine equations & send risk alerts
Please, answer the initial questions.
And it is difficult for me to read something with this INSERTANS stuff.
Better you use ExpressionScript.
1. I am sure you can shorten the equation by using
You have two equations "eqA" and "eqB"
So create a third "eqC" with
{if(eqA<100 and eqB<85,1,0)}
Now, if eqC is "1", send out, if it is "0", do not.
Joffm
Oh, and do not add the % sign; you won't be able to calculate eqC.
And it is difficult for me to read something with this INSERTANS stuff.
Better you use ExpressionScript.
1. I am sure you can shorten the equation by using
- suitable codes
- suitable functions
- some mathematical transformations
You have two equations "eqA" and "eqB"
So create a third "eqC" with
{if(eqA<100 and eqB<85,1,0)}
Now, if eqC is "1", send out, if it is "0", do not.
Joffm
Oh, and do not add the % sign; you won't be able to calculate eqC.
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 10 months 2 weeks ago by Joffm.
The following user(s) said Thank You: holch
Please Log in to join the conversation.
- mu_akubaraly
- Topic Author
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
10 months 2 weeks ago #228035
by mu_akubaraly
Replied by mu_akubaraly on topic Combine equations & send risk alerts
Thanks for getting back to me Joffm. I am still very new to Lime, apologies for the messy code. I managed to simplify it by creating a 3rd equation as follows:
{if(G03Q25.shown < 100 OR G03Q24.shown < 85, 1, 0)}
Im not sure if the above is correct? Can I use an "OR" statement in place of the "AND"?
Also with regards to the % sign, we cant remove this as we use it in a power query, is there any way to use another expression ? I've researched str_replace & intval but not sure how to use them:
intval((if(str_replace(G03Q25.shown, "%", " ") < 100 OR str_replace(G03Q24.shown, "%", " ") < 85, 1, 0)))
Really appreciate your assistance
{if(G03Q25.shown < 100 OR G03Q24.shown < 85, 1, 0)}
Im not sure if the above is correct? Can I use an "OR" statement in place of the "AND"?
Also with regards to the % sign, we cant remove this as we use it in a power query, is there any way to use another expression ? I've researched str_replace & intval but not sure how to use them:
intval((if(str_replace(G03Q25.shown, "%", " ") < 100 OR str_replace(G03Q24.shown, "%", " ") < 85, 1, 0)))
Really appreciate your assistance
Please Log in to join the conversation.
10 months 2 weeks ago - 10 months 2 weeks ago #228038
by Joffm
Have both equations to be fulfilled to send the mail? -> AND
Or only one of them? -> OR
As we learned at school in Boolean Algebra.
By the way: Both your equations - as you showed them before - do not give a result that is worth to compare.
equationA is either 0 or 100
equationB is either 0 (if equationA, which is included in equationB is 0) or has some percentage as result.
So it should be necessary at all to combine again.
And you should really read the manual about "this, self, that", "implemented functions" and "access to variables"
As said before:
You can simplify your two equations using:
{if(100-countif("No",that.Q804.sq_N1.NAOK)*100<100,0,100)}
equationB: (linefeeds inserted for more clarity)
{if(100-countif("No",that.Q804.sq_N1.NAOK)*100<100,0,round(sum(
countif("No",that.Q804.sq_N2.NAOK)*2,
countif("No",that.Q804.sq_N3.NAOK)*3,
countif("No",that.Q804.sq_N5.NAOK,that.Q804.sq_N1.NAOK)*5,
(5-countif("No",that.Q804.sq_R5.NAOK)*5),
(3-countif("No",that.Q804.sq_R3.NAOK)*3)
)/158*100,2))}
with:
Example:
Q804_SQ001 -> Q804_N501
Q804_SQ002 -> Q804_N202
Q804_SQ003 -> Q804_N203
Q804_SQ004 -> Q804_N304
Q804_SQ005 -> Q804_R305
Q804_SQ006 -> Q804_N206
Q804_SQ032 -> Q804_N132
This is not really tested.
I have no time to create something that might be similar to your survey.
So, for further questions you should send a lss export of these relevant questions.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Combine equations & send risk alerts
We do not know what your real condition is.{if(G03Q25.shown < 100 OR G03Q24.shown < 85, 1, 0)}
Im not sure if the above is correct? Can I use an "OR" statement in place of the "AND"?
Have both equations to be fulfilled to send the mail? -> AND
Or only one of them? -> OR
As we learned at school in Boolean Algebra.
By the way: Both your equations - as you showed them before - do not give a result that is worth to compare.
equationA is either 0 or 100
equationB is either 0 (if equationA, which is included in equationB is 0) or has some percentage as result.
So it should be necessary at all to combine again.
Of course, you can. The equation is is independent of what you do later with the result.Also with regards to the % sign, we cant remove this as we use it in a power query
And you should really read the manual about "this, self, that", "implemented functions" and "access to variables"
As said before:
You can simplify your two equations using:
- suitable codes
- suitable functions
- some mathematical transformations
{if(100-countif("No",that.Q804.sq_N1.NAOK)*100<100,0,100)}
equationB: (linefeeds inserted for more clarity)
{if(100-countif("No",that.Q804.sq_N1.NAOK)*100<100,0,round(sum(
countif("No",that.Q804.sq_N2.NAOK)*2,
countif("No",that.Q804.sq_N3.NAOK)*3,
countif("No",that.Q804.sq_N5.NAOK,that.Q804.sq_N1.NAOK)*5,
(5-countif("No",that.Q804.sq_R5.NAOK)*5),
(3-countif("No",that.Q804.sq_R3.NAOK)*3)
)/158*100,2))}
with:
- no use of "INSERTANS, but ExpressionScript
- question called "Q804" (I used this because the questionID was 804)
- "normal" calculated subquestion codes starting with "N"
- "reverse" calculated subquestion codes starting with "R"
- Codes weighted with "2" have a "2" in second place
- Codes weighted with "3" have a "3" in second place
- Codes weighted with "5" have a "5" in second place
- Three times used codes (31-37) have a "1" in second place
Example:
Q804_SQ001 -> Q804_N501
Q804_SQ002 -> Q804_N202
Q804_SQ003 -> Q804_N203
Q804_SQ004 -> Q804_N304
Q804_SQ005 -> Q804_R305
Q804_SQ006 -> Q804_N206
Q804_SQ032 -> Q804_N132
This is not really tested.
I have no time to create something that might be similar to your survey.
So, for further questions you should send a lss export of these relevant questions.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 10 months 2 weeks ago by Joffm.
Please Log in to join the conversation.