Results 1 to 3 of 3
  1. #1
    dr4ke is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    108

    Only show numeric values

    I have a query which does some mathematical calculations on my data. Some of the results are Text ('No Change' & 'Used Space Decreased') and the rest are all numerical values. Is there a way to pull out only the entries which have a numeric value bigger than 0?



    I've tried adding 'WHERE [TableName].[TimeLeft] >0' but it doesn't work.

    thoughts?


    Code:
     SELECT [7LUNQuery].SANName, [7LUNQuery].AggregateName, [7LUNQuery].LUNName, Int(Round(([7LUNQuery].FirstUsedAmount)/1024^2,0)) AS FirstUsedAmountGB, Int(Round(([7LUNQuery].LastUsedAmount)/1024^2,0)) AS LastUsedAmountGB, Int(Round(([7LUNQuery].FirstTotalAmount)/1024^2,0)) AS FirstTotalAmountGB, Int(Round(([7LUNQuery].LastTotalAmount)/1024^2,0)) AS LastTotalAmountGB, FirstTotalAmountGB-FirstUsedAmountGB AS FirstFreeAmountGB, LastTotalAmountGB-LastUsedAmountGB AS LastFreeAmountGB, Int(Round((FirstUsedAmountGB/FirstTotalAmountGB)*100,0)) AS FirstPercentageAmount, Int(Round((LastUsedAmountGB/LastTotalAmountGB)*100,0)) AS LastPercentageAmount, LastUsedAmountGB-FirstUsedAmountGB AS DifferenceUsedAmountGB, DateDiff("d",(Forms![FrontPage]![SelectStart]),(Forms![FrontPage]![SelectEnd])) AS DateDifference, Int(Round((DifferenceUsedAmountGB/DateDifference),0)) AS DailyIncreaseAmountGB, IIf([DailyIncreaseAmountGB]=0,'No Change',IIf([DailyIncreaseAmountGB]<0,'Used Space Decreased',Int(Round(LastFreeAmountGB/IIf(DailyIncreaseAmountGB=0,'Null',DailyIncreaseAmountGB),0)))) AS TimeLeft
    FROM 7LUNQuery;

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Why doesn't it work - error message, wrong results, nothing happens?

    Numeral characters sort before alpha characters in ascending alpha/numeric sort. So numeral strings will be < any alpha.

    TimeLeft is not a field in table, it is constructed by expression in query. Cannot reference constructed field in WHERE clause of same query. Must repeat the expression as the criteria. The TimeLeft expression is based on other constructed fields so still might fail.

    Suggest you build another query based on first query.
    Result of TimeLeft expression is either a text string or number value. I expect you will get 'data type mismatch' error with > 0 criteria.
    In second query, create field with expression: Val(TimeLeft). Criteria would be: > 0
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    dr4ke is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    108
    Hi!

    Sorry, yes that was the error message ('Data type mismatch'). I don't fully understand what you've said above, but I created another query and it works so I'm happy :-)

    Thanks,
    Dr4ke

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Setting Up DB with numeric values
    By dashingirish in forum Access
    Replies: 4
    Last Post: 02-17-2012, 03:41 PM
  2. Importing numeric fields with null values from XML
    By hcorvallis in forum Import/Export Data
    Replies: 1
    Last Post: 10-20-2011, 08:09 AM
  3. Importing Excel file. (2 non numeric values won't import)
    By Amerigo in forum Import/Export Data
    Replies: 3
    Last Post: 05-20-2011, 11:31 AM
  4. Updating Numeric Values
    By dssrun in forum Queries
    Replies: 9
    Last Post: 11-24-2010, 11:20 AM
  5. Show absolute values
    By Fluvio in forum Access
    Replies: 4
    Last Post: 08-16-2010, 09:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums