You are viewing limited content. For full access, please sign in.

Question

Question

CCOUNTIF Calculation Not Working

asked on May 30, 2018

Hello Everyone, 

 

I am trying to calculate the number of time the letter "V" (vacation) gets selected in a form I created (see screenshot.) The syntax appears to be correct because the "Total Vacation Days" field starts with the 0, but when I select "V" for one of the days. nothing happens. Here is my syntax

=COUNTIF([July_Week2.July_Week2_2, July_Week2.July_Week2_3],"=V") , for testing reasons I am only using 2 variables. 

 

Any thoughts? Thank you!

 

 

 

0 0

Replies

replied on May 30, 2018 Show version history

Is using JavaScript an option for you? You can probably do something like below. 

$(document).ready(function(){
   $('select.form-item-field').on('change',function(){
      $('#TotalVacation').val($('select option[value="V"]').length);
   });
});

Note that #TotalVacation has to be replaced with the actual id of your "Total Vacation Selected" field. To check the id of the field, hit F12 from your forms preview, select the cursor icon on the top right area, and click on the "Total Vacation Selected Field". In the example below, the id of my field is Field1, so I would replace #TotalVacation with #Field1.

Best,

Ken

0 0
replied on June 7, 2018 Show version history

Hi Ken, 

 

Thanks for replying. I'm picking this up for Matt, and have tried this script with the tweak that you describe, but I'm not getting anything unfortunately. Here's the script that I'm running. I'm trying to total up all of the W's to one field, and all of the V's to another. I think I'm also running into an issue where the value associated with the drop down value cannot have identical values. W and V should both equal 1, but Forms versions the second value to 1_1. Is there also a way to specify the values in the script rather than the field? 

 

Thanks for your help. 

 

Brian

 

Javascript.JPG
Javascript.JPG (33.67 KB)
0 0
replied on June 8, 2018 Show version history

Sorry the assumption was that all of the drop-down options had values of "V". I think you need to assign unique values to the drop-down. The code above should work if you assign your drop-down values as below. Is there any reason why they must be 1's?

UPDATE: after changing the option values to V's and W's please change the code as below:

$(document).ready(function(){
    $('select.form-item-field').on('change',function(){
        $('#Field1309').val($('select option[value="V"]').filter(':selected').length);
    });
     $('select.form-item-field').on('change',function(){
        $('#Field1310').val($('select option[value="W"]').filter(':selected').length);
    });
});

 

0 0
replied on June 8, 2018 Show version history

Hi Ken, 

Yes, the reason for the 1's is so that the W and the V will each be counted as one because they symbolize either a work day or a vacation day. Each kind must be tabulated for  the Workdays Total and Vacation Days Total fields. 

 

Thanks again for the help, 

 

Brian 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.