IF Function Format -- Microsoft Query

I am attempting to pull data from SQL data table into Excel for pivot table.  
Field_1 is a value; always positive.  Field_2 is a text flag; either "C" 
or"D".  Depending on the flag in Field_2; Field_1 is either positive or 
negative.  What is the format of the entry in Microsoft Query so that a 
Field_3 can accurately be calculated?

In Excel I would entry =if(Field_2="D",Field_1,-Field_1).
0
EShelly (1)
10/25/2004 10:03:04 PM
excel.misc 78881 articles. 5 followers. Follow

2 Replies
590 Views

Similar Articles

[PageSpeed] 28

In Access, the function would be IIF(Field_2="D",Field_1,-Field_1)

Unfortunately I have no idea whether it will work with your SQL data.

If that fails, you can always to the calculation on the worksheet before you
do the pivot table.


On Mon, 25 Oct 2004 15:03:04 -0700, "E Shelly"
<EShelly@discussions.microsoft.com> wrote:

>I am attempting to pull data from SQL data table into Excel for pivot table.
>Field_1 is a value; always positive.  Field_2 is a text flag; either "C" 
>or"D".  Depending on the flag in Field_2; Field_1 is either positive or 
>negative.  What is the format of the entry in Microsoft Query so that a 
>Field_3 can accurately be calculated?
>
>In Excel I would entry =if(Field_2="D",Field_1,-Field_1).

0
anonymous (74718)
10/25/2004 10:24:10 PM
Myrna Larson <anonymous@discussions.microsoft.com> wrote 

The standard SQL syntax, which Jet (MS Access) does not support, is
CASE e.g. using pubs from MS Query:

  SELECT 
    CASE title_id 
      WHEN 'BU1032' THEN 0 - royalty 
      ELSE royalty 
    END AS royalty_balanace 
  FROM pubs.dbo.roysched roysched
  ;

Jamie.

--
0
jamiecollins (192)
10/26/2004 11:04:14 AM
Reply:

Similar Artilces:

formula query
how do i display only formula in an excel spreadsheet? Hi do you want to display the formula text? -- Regards Frank Kabel Frankfurt, Germany "johan" <johan@discussions.microsoft.com> schrieb im Newsbeitrag news:A6E861AB-5BFF-4911-83A2-7B7D8849637C@microsoft.com... > how do i display only formula in an excel spreadsheet? Ctrl + ` (grave accent) will toggle between formula and non formula view you can also go to tools>options>view andf check formulas Regards, Peo Sjoblom "johan" wrote: > how do i display only formula in an excel spreadsheet? ...

ROUND Function with other function
Hi, I have this formula: =IF(R8>0,CONCATENATE("+",R8),R8) and the results shows me for example: +11.6 but what I really want t show is +12. I've been trying to put the "Round" function at a few places in th formula but it doesn't work. The closest I got was with this formula: =ROUND(IF(R8>0,CONCATENATE("+",R8),R8),0) where it showed me 12, without the "+" sign before.... Can anyone help me ? Thank -- Outapi ----------------------------------------------------------------------- Outapin's Profile: http://www.excelforum.com/member...

Excel 2007
In Excel 2003, one could select a cell, highlight a part of the contained text string and then right-clidk and format text. I could get underlining, bold, font, color, etc. For some reason, with Excel 2007, I can do the same, but when I hit the enter button, the formatting disappears. It reappears if I select the cell and press F2. Is there some setting that I have missed? ...

Query not working for SQL Server
I am trying to convert an Access backend database to SQL Server with an ODBC connection and linked tables from the Access frontend to the SQL Server backend. The SQL statements remain Jet SQL. I have a SELECT statement with a Datediff function that works in Access but not in SQL Server. The following works in the existing Access: SELECT DateDiff("n",startdateandtime+Nz(lunchtime,0),enddateandtime)/60) It does not work with SQL Server. The problem is with lunchtime. I tried removing lunchtime from the SQL Server version and that much works: SELECT DateDiff(...

Returning a range from an inner function
I have a range of data, which has had the DOLLAR() function performed on it. I would like to get the total of this range using the SUM() function. doing SUM(F1:F4) will not work, so I need to convert the data into values that will work. The VALUE() function is perfect for converting the data into values that will work for SUM(), but the formula SUM(VALUE(F1:F4)) does not work because VALUE() will not accept a range as a parameter (and also does not return a range). I need to perform the VALUE() function on each cell before submitting it to SUM(). There must be some way to do this, cons...

Translating Query formatting
I have a query that is set up to display records ordered by plan date then by start date. When I use the query in a report, it doesn't appear to sort the records. Is there a way to make the report format the results the same as the query? Thanks, Dragon Reports should always be sorted using the Sorting and Grouping dialog in Report Design. The order in the query often has no effect on the order in the report. -- Duane Hookom Microsoft Access MVP "Dragon" wrote: > I have a query that is set up to display records ordered by plan date then by >...

Conditional Formatting
Is it possible to format a portion of a text string within a cell (as opposed to the entire cell). For example, I would like to format the word 'gift' in red font anywhere it a appears in range C2:C417 but only that word, not the entire cell. Not with conditional formatting. But you could change the actual format for that word (or group of characters)... Saved from a previous post (or two!): If you want to change the color of just the characters, you need VBA in all versions. You want a macro???? Option Explicit Option Compare Text Sub testme() Application.ScreenUpdating ...

Array
Hi all. I'm trying to use for my first time, a single dimension array to use within an external sql query. I build the array from column A. This can be a variable amount, from 2 to 800. However, I can only use 150 rows at a time in the query. Below is what I have so far, in building the array. It's just the pulling out of 150 records at a time, or the remainder to put into the sql query. I will be building the sql query string as such: bug_number = (bug1,bug2,bug3) --these are the numbers in the array. (must have comma's between them) strQuery_main = "select dis...

JustifyString function problem
Hi, I'm using the "JustifyString" function (from Stephan Lebans) to right justify three columns in a ListBox. Two of them are working fine ... one's a simple number (long integer) and the other's currency. The third causes an Access 2003 crash! That third column is a long integer which is a link to the autonumber field in another table. Both tables are in the query as I need columns from both tables in the ListBox. If I change the JustifyString to reference the autonumber field in the other table, I still get an Access crash. I didn't review the Access er...

automating functions
I am a complete novice at CRM 1.2, but want to be able to create, for example, a workflow process that will monitor the CSR's and the queues and automatically assign a new case to the least busy CSR. Any input would be appreciated. Thanks in advance Jim Please tell me what I would have to do and with what tools in order to create such a workflow process. "jmb" wrote: > I am a complete novice at CRM 1.2, but want to be able to create, for > example, a workflow process that will monitor the CSR's and the queues and > automatically assign a new case to the lea...

Help Conditional Formatting
Help: I'm using conditional formatting on some cells to highlight particular values. The conditional formatting on 2003 only allows 3 levels of conditional formatting. Anyone know if there is a way to increase the number of levels? Thanks for any advice. -- Dab Cut off: yourhead to respond Hi conditional format only accepts 3 conditions though you have a fourth if you include the default format. If you only want to apply different FONT colors based on NUMBERS, you can define up to 6 different styles. See: http://www.mcgimpsey.com/excel/conditional6.html for instructions how to do...

Master Document: Separate Style Formatting in Subdocumnets
My book reading says that when you incorporate a subdocument into a master document that the style formatting gets overridden when you view the subdocument in the master document. I would like to know if it is possible to have each subdocument preserve its own style formatting outside the header/footer? Why would you do this and create inconsistent formatting? Glad you asked. The reason is I need to incorporate documents as appendices that need to be formatted as they originally were done. The inconsistency is not an issue --but rather a benefit as it shows they did come from a ...

Date in numeric format
I am trying to format dates in a spreadsheet. These dates are in a mixed format. They change to a five digit format (for e.g. 06/03/2005 is represnted by a five digit no. - 38417). I am unable to sort the date because it is not in the correct format even if I change it to date. Is there any way I can convert these numbers back to the date format therefore allowing me to sort them. Mnay thanks in advance -- Message posted via http://www.officekb.com Dates are just numbers with a special representation in the spreadsheet. Sorting should work regardless of how they are formatted. -- HTH Bo...

Viewing Query Total in Form
I have a form where I input purchases for customers. I also have a query that I use to make a report as a reciept to show the totals for items input. I have tried to make a text box to show the information from the total field in the query. However when I open the form it says "name?" is thre anyway to show the total from the query? Thank you for your help Chase W. ...

Returning a CHAR[] from a function
I have the following function that returns the path of where the program was run from. However I cant seem to return the butter as a CHAR. The code works if I use it in a procedure but not where I need to return the variable CHAR buffer. char CAutoRunDlg::GetProgramPath(void) { char buffer[_MAX_PATH]; //declares maimum path //opens window maximized //_getcwd(,)gets the current working directory // #include <direct.h> //needed for current working directory /* Get the current working directory: */ if( _getcwd( buffer, _MAX_PATH ) == NULL ) perror( "_getcwd error" )...

query help 04-14-10
using sql server 2005 sp3 32 bit i have a table that looks like this (pseudo coded) create table test (id int, parentid int, path varchar(200)) insert into test select 1, null, '/1/' insert into test select 2, 1, '/1/2/' insert into test select 3, 2, '/1/2/3/' insert into test select 4, null, '/4/' insert into test select 5, 4, '/4/5/' insert into test select 6, 5, '/4/5/6/' I need to produce a table that is flattened like this parentid, id null 1 1 2 1 3 2 3 null 4 4 5 4 ...

How To Get Excel To Stop Auto-Formatting my Column Data Types
Hi: I'm using Excel 2003. Anyone know how to get it to stop automatically choosing a data type for my columns? Some of its automatic features are nice but its auto data type sometimes gets in the way. Example, I run a program which exports data to Excel. The data contains fractions such as 5/6 and 6/6. When I open the newly-created Excel file, Excel converts those fractions to dates such as May 6 and June 6. If I could get to the worksheet ahead of time, I would format the column as text. But it's too late by the time I look at the worksheet and converting to text after Excel co...

problems with printing format for excel table in Publisher 2003
I took my Publisher 98 file with an Excel table, and loaded it into MS Publisher 2003. When I print out the page with the table, all the formatting lines of the table print, and I cannot find anywhere to get rid of them. It did not print them in Publisher 98. None of the autoformat options or border options on the task bar help. Any suggestions? Hi kuris, Best to change the Excel beforehand to remove both borders and gridlines, i would think. The round tripping aspects of Office leave a bit to be desired and one is usually much more comfortable in one Office application. The place ...

comment format
How does one set the default comment format (font, etc)? I hope I will succeed in translation - as my OS UI is in Hebrew. * Right click on an empty place in your DeskTop > 'Properties...' * Click the View [or is it display] Tab > 'Advanced' * Open the "Item" Combo-box and scroll down and click the "Tool Description' > choose the font SIZE > OK > OK. *** I don't think that changing the font type and/or color will affect the Comments in Excel. *** Pay attention that this procedure will change all *** There is no problem to write...

Turning Off Error Reporting using API Functions and VB
We want to automatically turn off the error reporting options using Windows API functions for the following functions area Click on Start, Settings, Control Panel, System, the Advanced tab and Error Reporting (at the bottom of the screen), which launches the Error Reporting screen. Another way to get to that screen: Open My Computer, right-click on Properties, click on Advanced tab and Error Reporting. Any assistance would be welcome. It's not a program's call. It's the user's decision. --=20 -------------------------------------------------------------------------= --...

Complex functions
Hi All, Suppose you have a very complex and long function that is also subject to a condition, then you will/can have something like: =if(condition(complex function), complex function, other complex function) It can have more lines in the formula bar, so readability below 0 Kelvin. Is there a way to 'name' a function? =If(condition(myfunc = complex function), myfunc, other complex function) With kind regards, JP Yes you can put a formula into an Excel Name (the same as you can give a range an Excel Name. Very powerful it can be too. Do a Google fo...

Match Function
Hi, I have put together a spreadsheet to find codes, states, descriptions. It finds the data by dates. Columns are: Dates, Codes, States, Descriptions If I put in a date it matches the code, state and description. My problem is that if I have 2 dates that are the same it will only match the first date it can find. What kind of formula do I need so that it will output the second or third date data. Thanks for your help. If you need a copy of the spreadsheet please let me know. How many rows of data do you have? -- Biff Microsoft Excel MVP "Melanie" <Melanie@discussio...

copy formatted text
When copying text from Word that contains an if/then argument, as well as mail merge fields, all formatting is lost. Paste special does not appear to work for this, either. What am I doing wrong? I'm using Pub 2003, Word 2000, and Win XP. Thanks, JR Percy Cousins wrote: > When copying text from Word that contains an if/then argument, as well as > mail merge fields, all formatting is lost. Paste special does not appear to > work for this, either. What am I doing wrong? I'm using Pub 2003, Word 2000, > and Win XP. This is not supported in Publisher. -- Brian Kv...

Report Formatting Problems
We're trying to design our invoices to fit our preprinted forms (we would do it the other way around, but we have 10 cases of invoice paper left!) and I'm having difficulty with Report Writer. I'm wondering if someone can help: 1) Is it possible to change the font of a field OTHER then changing the DPI of the whole report? 2) Is it possible to wrap a field, such as the Long Description field, so that it will fit in a fixed width column? I am perplexed that there is not more functionality in the report design in a Microsoft product such as this. Thanks for any tips y...

format cell problem
Hi, I do not arrive to create this personalized format who is responding to these 3 conditions (number is displayed in percentage). 1) if < 0 the colour must be red 2) if < 10 the value must be replaced by "NS" 3) if > 10 then value must be replace by "NS" the only think have found is : [<+10]"NS";[Red]-0,0%;0,0% with this format steps1,3 are ok but impossible to integrate step 2 is anybody can help me !! it's important for me.. thanks in advance Alex One way: [Red][<=0]0.0%;"NS" Note that you didn't specify what sh...