Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
335
UltraGrid: Sum of column with only Null values in groupby results in 0,00 instead of Null
posted

Hi,

We use an UltraGrid in which we group rows and take the sum of values in columns. This sum is shown in the header. See the screenshot below. The red circles are wrong, the green circles are ok.

However, for columns of which ALL values within the group are Null (or Nothing), the Sum evaluates to 0,00 instead of Nothing. I looked at how this work for SQL queries. Here, a sum of all Null values evaluates to Nothing: SELECTSUM(Null) = Nothing (instead of 0,00)..

Does anyone have any idea whether this is possible, so that in the header we get Nothing instead of 0,00?

See below for a relevant piece of our code

Best regards, Henk Wagterveld

      With e.Layout.Bands(0)
        With .Columns("Turnover".ToLower)
            .Style = ColumnStyle.Currency
            .Format = FormatUIlib.DefaultCurrencyFormat
            .CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right
            .Header.Caption = "Grondslag" '= Dutch translation of Turnover
            .Header.Appearance.TextHAlign = Infragistics.Win.HAlign.Right
            .Width = 77
            .Header.VisiblePosition = 4
            .Hidden = False
          End With
          With .Columns("VatAmount".ToLower)
            .Header.VisiblePosition = 5
            .Style = ColumnStyle.Currency
            .Format = FormatUIlib.DefaultCurrencyFormat
            .CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right
            .Header.Caption = "Btw-bedrag" '=Dutch translation of Vat-amount
            .Header.Appearance.TextHAlign = Infragistics.Win.HAlign.Right
            .Width = 87
            .Hidden = False
          End With
        End If
      End With

      'Sum for  op turnover and value added tax.
      With e.Layout.Bands(0)
        .Summaries.Clear()
        .Summaries.Add("Turnover", SummaryType.Sum, .Columns("Turnover"), SummaryPosition.UseSummaryPositionColumn).DisplayFormat = "{0:0.00}"
        .Summaries.Add("VatAmount", SummaryType.Sum, .Columns("VatAmount"), SummaryPosition.UseSummaryPositionColumn).DisplayFormat = "{0:0.00}"
      End With

      With e.Layout
        'Group by funcionality
        .Grid.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy
        'Hide GroupBy UI
        .Grid.DisplayLayout.GroupByBox.Hidden = True
        'Group
        With .Grid.DisplayLayout.Bands(0)
          If .SortedColumns.Exists("GroupByMembers") = False Then
            .SortedColumns.Add("GroupByMembers", False, True)
            .SortedColumns(0).AllowGroupBy = Infragistics.Win.DefaultableBoolean.True
          End If
        End With
      End With

 

Parents
  • 469350
    Offline posted

    Hi,

    I'm pretty sure that all of the built-in summary types (such SummaryType.Sum) are going to interpret a null in a numeric field as a 0. And I suspect the same is true if you use a Formula.

    So if you want finer control over this, I think you will have to create your own ICustomSummaryCalculator This gives you the ability to handle the calculation yourself and you can deal with nulls however you like.

Reply Children