Subtotal Average Percentage Decimal Place

Good afternoon,
I have a dashboard that groups results and applies a sum to one column and an average to another column. Here you can see the average being applied to the efficency percentage. While the calculation is correct, I would like to see the results in the same decimal format as my data. Is that possible?
image

In this example, I want the average to be 24.67% instead of .25

Any ideas? Thanks!
Nate

You’re asking too much, sir. :rofl:

2 Likes

I know I can always count on you to give it to me straight!

I think that’s why they stopped asking me to do customer reference calls for prospectives. LOL

2 Likes

Okay–so it turns out I CAN be useful… :smiley:

Set your format however you need it. I just happened to throw random stuff in there because… well. Shrug

public void InitializeCustomCode()
{
		EpiUltraGrid myGrd = (EpiUltraGrid)csm.GetNativeControlReference("4d59326f-7a76-4c5c-8e2c-54e630db64da");
		var QtyCol = myGrd.DisplayLayout.Bands[0].Columns["XRelQty"];

		var summarySettings = myGrd.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum,QtyCol);
		summarySettings.DisplayFormat = "Sum: {0:P1}";
}
2 Likes

Huh–I can only get that format to work with the SUM everything except the Average aggregate. Average is being annoying.
Wtf, lol.

1 Like

Okay, so it seems to be a timing issue with the Average…

using Infragistics.Win.UltraWinGrid;

public class Script
{
	EpiUltraGrid myGrd;
	SummarySettings summarySettings;

	public void InitializeCustomCode()
	{
		myGrd = (EpiUltraGrid)csm.GetNativeControlReference("4d59326f-7a76-4c5c-8e2c-54e630db64da");
		var QtyCol = myGrd.DisplayLayout.Bands[0].Columns["XRelQty"];
	
		summarySettings = myGrd.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Average,QtyCol);
		summarySettings.DisplayFormat = "{0:P1}";
	}

	private void edvSugPoDtl_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
	{
		if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
		{
			if ((args.Row > -1))
			{					
				summarySettings.DisplayFormat = "{0:P1}";
			}
		}
	}
}

It gets the job done. ¯\_(ツ)_/¯

2 Likes

Dang, you’re good! I’ll study this and apply it to my dash.
Thank you!!!

1 Like

I can’t seem to get it. The codes doesn’t return any errors, but it isn’t changing the average into a %. Maybe there is still a timing issue going on? Here’s my version of your code:

// **************************************************
// Custom code for MainController
// Created: 7/12/2022 8:33:51 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Infragistics.Win.UltraWinGrid;

public class Script
{
	EpiUltraGrid myGrd;
	SummarySettings summarySettings;
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	private EpiDataView edvV_EarnedHours_1View;
	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **


	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		this.edvV_EarnedHours_1View = ((EpiDataView)(this.oTrans.EpiDataViews["V_EarnedHours_1View"]));
		this.edvV_EarnedHours_1View.EpiViewNotification += new EpiViewNotification(this.edvV_EarnedHours_1View_EpiViewNotification);
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		// End Wizard Added Custom Method Calls
		myGrd = (EpiUltraGrid)csm.GetNativeControlReference("ed78aa51-6f56-4645-81cb-4e74292f54bb");
		var QtyCol = myGrd.DisplayLayout.Bands[0].Columns["Calculated_EmpEff"];
	
		summarySettings = myGrd.DisplayLayout.Bands[0].Summaries.Add("Avg", SummaryType.Average,QtyCol);
		summarySettings.DisplayFormat = "{0:P1}";
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		this.edvV_EarnedHours_1View.EpiViewNotification -= new EpiViewNotification(this.edvV_EarnedHours_1View_EpiViewNotification);
		this.edvV_EarnedHours_1View = null;
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void edvV_EarnedHours_1View_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
	{
		// ** Argument Properties and Uses **
		// view.dataView[args.Row]["FieldName"]
		// args.Row, args.Column, args.Sender, args.NotifyType
		// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
	
		if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
			{
				if ((args.Row > -1))
				{
					summarySettings.DisplayFormat = "{0:P1}";
				}
			}
	}
}

1 Like

Yeah, I’m sure the dashboard is doing something stupid, lol. Lemme look.

How do you track down timing issues? This is one case where debugging in Kinetic with the browser dev tools really helps.

Debug with Visual Studio, set a bunch of break points, then step through it.

1 Like

OK I’m on it. I can use the summarySettings to change other things about the summary row, like position above and below. But changing the format seems to be stuck. Thanks for the guidance!

Do you always have to close epicor after debugging in VS? I always get the message to restart epicor to allow VS to debug again. Even though VS is closed. Just an annoying quirk?

Just leave VS open the entire time. When you start a new debugging session, it will open a new tab in VS.

1 Like

Well, it’s not ideal as it doesn’t seem to fire until you click into the grid, but it’s something?

	private void edvV_13187_1View_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
	{
		// ** Argument Properties and Uses **
		// view.dataView[args.Row]["FieldName"]
		// args.Row, args.Column, args.Sender, args.NotifyType
		// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
		if( summarySettings != null )
		{
			summarySettings.DisplayFormat = "{0:P1}";
			summarySettings.Appearance.TextHAlign = Infragistics.Win.HAlign.Right;
		}
	}

Thank you! I keep trying different DisplayFormats. Infragistics shows this for an average:

avgSummary.DisplayFormat = "Avg = {0:#####.00}";

I also tried your format. As well as a few other even simpler formats. I also added the % sign into the format in various way.
None of these changes seem to make any difference to the way the average is displayed. I don’t see any strange timing issues. The EpiViewNotification fires twice. Once when the form loads, without any data so Row = -1. Then it fires again after I have entered my parameters, and the data gets loaded.
Quite a strange behavior!

I think {0:P1} is going to be what you want–it’s for percentages.

SummaryFormat

Weird! Mine doesn’t do that. It just stays as the regular old decimal. Debugging seems to show that the display format gets set as you described. But, if I refresh the form and look at the display format value it has reset itself to “Average = {0:############.00}”.

Does it matter if I am using a dashboard assembly? I never use dashboard runtime.