Forum Discussion

RandyThompson's avatar
RandyThompson
New Contributor III
2 years ago

How can we show commas as the thousand separator in a numeric Table View column

We are trying to format numeric columns in a Table View but haven't been successful. The numeric columns are currently appearing as 999999.99 instead of the desired 99,999.99. Are Table View currently looks like this:

The Spreadsheet Table View rule is defining the numeric columns here:

sql.AppendLine( ",FORMAT(SUM(ISNULL([V4],'0')),'N2','en-us') As [Gross Revenue]")

Thanks

  • RobbSalzmann's avatar
    RobbSalzmann
    Valued Contributor II

    Could you try formatting the number in your sql query?

    SELECT FORMAT(SomeNumericColumn,'#,0.00') from SOME_TABLE

  • RandyThompson's avatar
    RandyThompson
    New Contributor III

    I tried that and it didn't work. Table View seems to be ignoring the SQL formatting and applying their formatting based on the table view column definition.

  • Randy, you will have to get rid of the column format and use the populate from data table option with the keep format from data boolean.

    • RandyThompson's avatar
      RandyThompson
      New Contributor III

      Thanks, Celvin. Unfortunately I can't find any documentation on this. Can you share a snippet of code of how to use the populate from data table. Thanks.

      • JackLacava's avatar
        JackLacava
        Honored Contributor

        Didn't test this but it should work.

        ' assuming yourDataTable will have been obtained already
        Dim includeColHeaderRow as Boolean = True
        Dim useDataTypes as Boolean = True  ' try switching this on/off to compare results
        args.TableView.PopulateFromDataTable(dataTable, includeColHeaderRow, useDataTypes)
        return args.TableView