# Does matrix filter support EM?

2 years 10 months ago - 2 years 10 months ago #107677 by orvil
Hi,

currently I'm trying to use an expression for a matrix filter. Is this supported by LS?

An example:
1) Question A is a simple two way choice like Y/N
1) Questions B and C, both are multiple selections, same subquestions SQ001, SQ002, ... of course
2) Questions D is a matrix question, again with subquestions named SQ001, SQ002, ...

Now I'd like to have the subquestion of question D being filtered either by question B or question C depending on question A with an expression like:

if(questionA == "Y",questionB, questionC)

witch means "use questionB as matrix filter for question D if questionA is "Y". Otherwise use questionC as matrix filter for questionD"

Any ideas???

Best regards/Beste Grüße,
O. Villani
Last Edit: 2 years 10 months ago by orvil.

2 years 10 months ago #107680 by first
Step1:Create an equation type question (eq) after question C.
Step2:Create a multi question (D) after question eq with the same answer list and A and B.
Step3: Use D as Array filter .
step4:Hide D from question settings
Step 5: Write below equation in eq.

{D_SQ001=if((('B_SQ001.NAOK' == 'Y')||('C_SQ001.NAOK' == 'Y')),'Y','')}

I have not tested the above equation but I sure you got the idea.

Survey Designer and Programmer
"I always suggest to have a group by group display layout and create a seprate group for each question. This will be extra work but you will get flexiblity to create your question by using more than more lime survey question types."
The following user(s) said Thank You: orvil

2 years 10 months ago #107693 by orvil
Hello,

thanks I see your approach and it's surely working well. But unfortunately this does not solve my problem.

The example I gave was only a brief abstraction. That is why I belive I need to directly adress different questions (or in some cases none) within the array filter field (of question D in my example).

To be more detailed, I do have:
-a question A (it is in reality an equation giving a number between 1 and 25)
-a question B (it is a hidden multiple selection with 5 subquestions SQ001 to SQ005 and depending on A the subquestions are filled by an EM with 1 or they are empty)
-a question C (same like B, other EM formula) - maybe I can dispense this question, dont know at the moment

- at last: 5 questions D (D1, D2, ..., D5 all with 5 subquestions SQ001 to SQ005

Now: Depending on the result of A (a value between 1 to 25) only a part of the 5 D-questions are shown
if A <= 5 only D1
if A <= 11 D1 and D2
if A <= 16 D1, D2 and D3
if A <= 20 D1, D2, D3 an D4
if A > 20 all (D1,D2,D3,D5,D5) are shown

The point is: only the LAST ONE of the D's has to be filtered by question C, all other (i.e. D1 to D(n-1) ) has to be filtered by question B (or may be I will not need any filter for these not-the-last ones).

So for example:
if result of A == 14 then
D1 and D2 has to be filtered by question B (or may be not being filtered)
D3 has to be filtered by question C

(D4 and D5 are not visible by relevance equation)

Another example:
if result of A == 22
D1, D2, D3, D4 has to be filtered by question B (or may be not being filtered)
D5 has to be filtered by question C

A little bit complicated, kind of brainteaser, I know

Best regards/Beste Grüße,
O. Villani

2 years 10 months ago #107697 by first
Please create this situation in a test survey and attach lss here. I will try to help.

Survey Designer and Programmer
"I always suggest to have a group by group display layout and create a seprate group for each question. This will be extra work but you will get flexiblity to create your question by using more than more lime survey question types."

2 years 10 months ago #107702 by orvil
Hello,

did so. Hope it is self explaining

Best regards/Beste Grüße,
O. Villani
##### Attachments:

2 years 10 months ago - 2 years 10 months ago #107708 by first
Solution:-
Create questionB for each questionD.
Update each questionB in array filter of questionD.
Only show questionB corresponding to last questionD.

We can also do it with java script.

Survey Designer and Programmer
"I always suggest to have a group by group display layout and create a seprate group for each question. This will be extra work but you will get flexiblity to create your question by using more than more lime survey question types."
Last Edit: 2 years 10 months ago by first.

2 years 10 months ago #107709 by orvil
Hi Trivender,

creating a filter question for every questionD is what I'd really like to avoid - because of the resulting database size => every filter subquestion leads to one more field . Ideally I'd like to avoid as much datafields as possible.

So JavaScript is may be another approach. Are there any js-only solutions jet? Found something in the js workarounds, but not matching the subquestions problem as far as I can understand the code.

Best regards/Beste Grüße,
O. Villani

2 years 10 months ago #107711 by first
Save below code in source of questionB and let me know how it looks.
```<script>
\$('ul.subquestions-list input:text').each(function(){
if(\$.trim(\$(this).val()) == ""){
\$('table.subquestions-list:visible:last tbody tr').eq(\$('ul.subquestions-list input:text').index(this)).hide();
}
});
});
</script>```

Survey Designer and Programmer
"I always suggest to have a group by group display layout and create a seprate group for each question. This will be extra work but you will get flexiblity to create your question by using more than more lime survey question types."
The following user(s) said Thank You: orvil

2 years 10 months ago #107716 by orvil
Hi Trivender,

works great if questions are in the same group and shown group by group. THANKS!
Is it possible to use your tweak if questions are show in question by question mode too? (as you may see my jquery knowledge is poor )

Best regards/Beste Grüße,
O. Villani

2 years 10 months ago #107745 by first
I think we can do it even if questions are on different page . If you can create a desired test survey and attach lss here I will try.

Survey Designer and Programmer
"I always suggest to have a group by group display layout and create a seprate group for each question. This will be extra work but you will get flexiblity to create your question by using more than more lime survey question types."

2 years 10 months ago #107818 by orvil
hello,

would be really great if this is possible!

THX

Best regards/Beste Grüße,
O. Villani