Get Free Trial

Count/filter on multiple choice fields

Answered
Rignald Span asked on July 1, 2022

Dear Support,
Another question we have is regarding multiple choice questions and how to display them.
If I have a question regarding Where somebody does their shopping?
“Shopping”: “3;4”,
With 3=Shop Three and 4=Shop Four
Is is then possible within Flexmonster to do a count or filter on how many times for example Shop Three was choosen?
 
Best Regards,
Rignald

3 answers

Public
Maksym Diachenko Maksym Diachenko Flexmonster July 4, 2022

Hello, Rignald!

Thank you for reaching out to us.

Yes, it is possible to filter the occurrence of the specified string in the list of visited shops:

1) Firstly, you should set the Shopping field type as string inside the MappingObject:

Shopping: {
   type: "string"
}

With the string type, the default field’s aggregation is count.

2) To set the filter to see the count of visits to one shop, we recommend using the contain filter:

filter: {
   query: {
      contain: "3"
   }
}

Check this JSFiddle example for reference: https://jsfiddle.net/flexmonster/k0m5gsow/
 
Alternatively, you can preprocess the data, so each Shopping field will contain only one shop number. With this approach data structure is changed, and we recommend using members filter:

filter: {
   members: [
      "shopping.[3]"
   ]
}

Please see the following example: https://jsfiddle.net/flexmonster/y32hx1gf/

Feel free to contact us if further questions arise.

Best Regards,
Maksym

Public
Maksym Diachenko Maksym Diachenko Flexmonster July 12, 2022

Hello, Rignald!

Hope you are doing well.
We would like to know whether you had time to try the suggested approach for filtering the count of visited shops. 
Looking forward to your reply.

Best Regards,
Maksym

Public
Maksym Diachenko Maksym Diachenko Flexmonster July 19, 2022

Hi, Rignald!

Our team is wondering if you tried the provided solution.
Please let us know if it works for your case.

Best Regards,
Maksym

Please login or Register to Submit Answer