How do you display the question type - Constant sum with total (Matrix table), in your dashboard? | XM Community
Solved

How do you display the question type - Constant sum with total (Matrix table), in your dashboard?

  • 26 March 2018
  • 5 replies
  • 87 views

I asked the respondents to allocate their work tasks from 0-100% making the total allocated percentage a 100%. I used the Matrix table - Constant sum with total for asking this question in my survey. I'm unable to find a widget to display this question in my dashboard. Has anyone come across a similar situation.
icon

Best answer by Michael_Campbell_RedPepper 27 March 2018, 17:51

View original

5 replies

Userlevel 4
Badge +3
Yeah! If you're familiar with Javascript, I can walk you through it! We had a similar situation come up earlier on the discussion board.

Are you familiar with JS?
Thanks a lot Micheal. I am a bit familiar with JS. Will be happy to have a discussion. What's the best way we could connect?
Userlevel 4
Badge +3
For sure! I'm trying to post my answer, but I'm having issues on my end.. one sec.
Userlevel 4
Badge +3
I think this discussion board is fine - I want to make sure this solution is available to any others who are searching for it later, but if it gets too complex or involved, I can DM you!

If you're familiar with jQuery, you can do the following (I'm going to explain it conceptually, and if that doesn't do the trick, we can dive into the actual code. Don't be concerned if you don't understand, but I encourage experimentation and engaged learning so you can adjust to the platform through the process).

- Use `$('#xx')` notation to capture references to each of the fields in your Matrix table
- Put an `.on('change' () ={})` listener to those captured fields
- When the `change` method is called, then get the sum of the fields, and then update the value of your display.

Here is some sample code (not usable in the API)

Let's say your matrix question rows have a class` 'matrix-row'`, and your Display field has an id of 'sum-display';

You would go like this:
Userlevel 4
Badge +3
Hm... it won't let me post the code snippet...

Here is some JQuery Documentation to get you started!


- How to set values in jQuery
http://api.jquery.com/val/

- On Change Listeners in jQuery
https://api.jquery.com/change/

- How to select items in jQuery
https://www.w3schools.com/jquery/jquery_ref_selectors.asp

Leave a Reply