average total type on vLookup

Home Forums vLooup for SharePoint average total type on vLookup

Viewing 5 reply threads
  • Author
    Posts
    • #9218
      Tony Bowes
      Participant

        I’m attempting to provide an average percentage as a total on a percentage column. I can add {“average”:true} to the column, but it still remains an aggregate total. Not sure if it’s anything to do with the column type being a percentage as I cannot get it to trigger on other numeric fields either.

        Using DFFS 4.359

      • #9250
        Alexander Bautz
        Keymaster

          Hi,
          It seems there is a bug in the tooltip help text – use this format in the “Special configurations”:

          {"percentage":true,"suffix":"%","totalsType":"average"}

          Sorry for the inconvenience – I’ll update the tooltip in the next release.

          Alexander

        • #9270
          Tony Bowes
          Participant

            Thanks, your solution works.

          • #9355
            Tony Bowes
            Participant

              I am attempting to average another field which is a checkbox. The values are presented as “Yes” or “No” strings and thus not eligible for aggregation. I can get to the vLookup.dataObj to do a manual count, but I’m wondering if there is a way to present the Boolean as 1 or 0 and aggregate normally? This total will also hopefully be a percentage.

              Here’s my current tests for a manual count:

              function getSignificantEventsPercent() {
              	console.log(spjs.vLookup.dataObj);
              	console.log(spjs.vLookup.dataObj.vLookupSURsignificantEvents[1].count);
              	console.log(spjs.vLookup.dataObj.vLookupSURsignificantEvents[1].items[1].Significant_x0020_Event_x0020_KP);
              	var countKPImet = 0;
              	for (var currentItem = 1; currentItem <=  spjs.vLookup.dataObj.vLookupSURsignificantEvents[1].count; currentItem++){
              		if (spjs.vLookup.dataObj.vLookupSURsignificantEvents[1].items[currentItem].Significant_x0020_Event_x0020_KP == "Yes") {
              			countKPImet++;
              		}	
              	} // For currentItem
              	console.log(countKPImet);
              }
              • This reply was modified 9 years, 1 month ago by Tony Bowes.
              • This reply was modified 9 years, 1 month ago by Tony Bowes.
            • #9365
              Tony Bowes
              Participant

                Sidestepped it by updating a rollup field instead:

                function getSignificantEventsPercent() {
                	var countKPImet = 0;
                	var allFinalised = true;
                	for (var currentItem = 1; currentItem <=  spjs.vLookup.dataObj.vLookupSURsignificantEvents[1].count; currentItem++){
                		if (spjs.vLookup.dataObj.vLookupSURsignificantEvents[1].items[currentItem].Significant_x0020_Event_x0020_KP == "Yes") {
                			countKPImet++;
                		}
                		if (spjs.vLookup.dataObj.vLookupSURsignificantEvents[1].items[currentItem].Finalised == "No") {
                			allFinalised = false;
                		}
                	} // For currentItem
                
                	if (allFinalised) {
                		if (spjs.vLookup.dataObj.vLookupSURsignificantEvents[1].count > 0) {
                			var newSignificantEventPercent = Math.round((countKPImet/spjs.vLookup.dataObj.vLookupSURsignificantEvents[1].count) * 100);
                			console.log(newSignificantEventPercent); // debug
                			setFieldValue("SU_x0020_Significant_x0020_Event",newSignificantEventPercent);
                		}
                		$("span.FinalisedWarning").html(""); // clear warning
                	} else {
                		$("span.FinalisedWarning").html("Not all Service User Reports finalised!");  // show warning
                	} // allFinalised
                } // getSignificantEventsPercent
                
                function vLookupIsLoadedCallback(fin){
                	if(fin === "vLookupSURsignificantEvents") { getSignificantEventsPercent(); }
                }
                • This reply was modified 9 years, 1 month ago by Tony Bowes.
              • #9368
                Alexander Bautz
                Keymaster

                  I’m glad you figured it out, and thank you for the “beer” donation.

                  Best regards,
                  Alexander

              Viewing 5 reply threads
              • You must be logged in to reply to this topic.