Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Why Datatable.Compute("MAX([Table]","") is not retrieving correct values with 3 digit numerics.

Why Datatable.Compute("MAX([Table]","") is not retrieving correct values with 3 digit numerics.

Scheduled Pinned Locked Moved ASP.NET
tutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SIJUTHOMASP
    wrote on last edited by
    #1

    Hi, I am using Datatable.Compute("MAX([Table]","") to get the Minimum value in a column. It is getting correct values only if the column contains 2 didgit numbers. For example if amy column contains the values 100,180,85 like that,then it is not getting correct values.In this cas it getting 100 instead of 180.How to resolve this. Please show me the right way.. Thanks RPM.

    G 1 Reply Last reply
    0
    • S SIJUTHOMASP

      Hi, I am using Datatable.Compute("MAX([Table]","") to get the Minimum value in a column. It is getting correct values only if the column contains 2 didgit numbers. For example if amy column contains the values 100,180,85 like that,then it is not getting correct values.In this cas it getting 100 instead of 180.How to resolve this. Please show me the right way.. Thanks RPM.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Rahul.P.Menon wrote:

      I am using Datatable.Compute("MAX([Table]","") to get the Minimum value in a column.

      I am quite sure that you don't. The syntax of the formula is not correct, and you can't use MAX to get a minimum... Show the code that you are actually using, instead. It's impossible to find the error you are looking for in code that doesn't even contain the error, but contain other errors instead. What is the data type of the field you are trying to get the minimum/maximum from? If you are comparing text, remember that "85" > "100".

      --- Year happy = new Year(2007);

      S 2 Replies Last reply
      0
      • G Guffa

        Rahul.P.Menon wrote:

        I am using Datatable.Compute("MAX([Table]","") to get the Minimum value in a column.

        I am quite sure that you don't. The syntax of the formula is not correct, and you can't use MAX to get a minimum... Show the code that you are actually using, instead. It's impossible to find the error you are looking for in code that doesn't even contain the error, but contain other errors instead. What is the data type of the field you are trying to get the minimum/maximum from? If you are comparing text, remember that "85" > "100".

        --- Year happy = new Year(2007);

        S Offline
        S Offline
        SIJUTHOMASP
        wrote on last edited by
        #3

        Hi Guffa, Thanks for thr reply..This is the code I have used to find min.. Dim expr As String = "MIN([" & dtn.Columns(1).ColumnName.ToString & "])" Dim min, max As Double min = CType(dtn.Compute(expr, ""), Double) And that datattable column,I have tried is of System.string and system.double. But in both cases I am not getting the correct values if the column value contains more than 2 digits. Pls help me.. Thanks RPM.

        1 Reply Last reply
        0
        • G Guffa

          Rahul.P.Menon wrote:

          I am using Datatable.Compute("MAX([Table]","") to get the Minimum value in a column.

          I am quite sure that you don't. The syntax of the formula is not correct, and you can't use MAX to get a minimum... Show the code that you are actually using, instead. It's impossible to find the error you are looking for in code that doesn't even contain the error, but contain other errors instead. What is the data type of the field you are trying to get the minimum/maximum from? If you are comparing text, remember that "85" > "100".

          --- Year happy = new Year(2007);

          S Offline
          S Offline
          SIJUTHOMASP
          wrote on last edited by
          #4

          Guffa, You are right 100%..The mistake was with the code only.. As you said when I used the column type of system.Double instead of system.String it is giving correct values... Thanks very much for the great help and much appreciating. Thanks again, RPM.

          SoftwareDeveloper(.NET)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups