Replace Null With Zero In Crosstab Query

Jan 9, 2006

Hello.

I have a simple crosstab query, which is designed to give a monthly total (numeric) and a yearly total for the value of orders placed by a number of customers.

The query is based on another query which simply extracts order records for a particular year.
For some customers, certain months will be blank as there were no orders placed.
I would like to use the crosstab query on a report, and I would like to replace the blanks with zeros.
I have searched for examples of query expressions using the nz function and attempted to apply some. I have, however, had no success in converting the blank monthly totals to zeros.

Can anyone help me achieve this?

The query is as follows :

TRANSFORM Sum(AmountQueryLastYear.SumOfAmount) AS SumOfSumOfAmount
SELECT AmountQueryLastYear.DeliveryName, Sum(AmountQueryLastYear.SumOfAmount) AS [Total Of SumOfAmount]
FROM AmountQueryLastYear
GROUP BY AmountQueryLastYear.DeliveryName
PIVOT Format([ShipmentDate],"mmm") In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

An example of expressions I have tried is :

Expr1: NZ([SumOfAmount],0)

In it's own column in the query design grid.

View Replies


ADVERTISEMENT

Modules & VBA :: Replace Null Value

Nov 10, 2014

Is there a code that will replace the empty fields by shifting the bottom fields up for access? I am planning to write a code that will delete unnecessary items in my database, however, that will cause the database to have "holes" in it.

View 4 Replies View Related

Queries :: Replace Null With Currency Zero?

Jul 31, 2013

I have always relied on Design View to create my queries, usually with great success, but in so doing, I have not become familiar with SQL view, so can't solve this problem:

I have a very simple query whose only function is to sum the payment amounts received for each contract number:

SELECT Payments.[Contract Number], Sum(Payments.[Payment Amount]) AS [SumOfPayment Amount]
FROM Payments
GROUP BY Payments.[Contract Number];

It is then used in subsequent queries to create an accounts payable report. It works great as long as at least one payment has been received on the contract, but if NO payments have ever been received, the Sum is actually null, so that record doesn't get included. I need a way for this query to return zero or currency zero 0.00 for all contracts with no payments yet, so those contracts will be included and the next query in line will see a zero.

In my search, it seems I need to make use of the IsNull function in my SQL (the check expression would be the sum of payments, the replacement value would be zero) OR I need to include a WHEN or WHERE in my SELECT statement above? I just don't know enough about SQL to make this happen .

View 8 Replies View Related

Queries :: Make Replace Query To Look In Order To Find What To Replace

May 6, 2014

I have this working query:

Code:
INSERT INTO TB_SISTEMAS ( LOGIN, SISTEMA, PERFIL, DATA )
SELECT Left([dbo_BACKUP_ACESSOS.LOGIN],255) AS LOGIN, dbo_BACKUP_ACESSOS.SISTEMA, Left([dbo_BACKUP_ACESSOS.PERFIL],255) AS PERFIL, dbo_BACKUP_ACESSOS.DATA
FROM dbo_BACKUP_ACESSOS
WHERE (((dbo_BACKUP_ACESSOS.SISTEMA)<>"ACTIVE DIRECTORY") AND ((dbo_BACKUP_ACESSOS.DATA)="2014-03-23"));

But Iwant to be able to use a set of data to be used in the Replace Statement, so I create a table to add each string I would like to have replaced by "nothing", and trying to make the replace query to look there in order to find what to replace.I also created a table where I will list the systems that I dont want in the select, so I removed the "ACTIVE DIRECTORY" and replaced by the colum that have the list of system I dont want listed.This is the result:

Code:
INSERT INTO TB_SISTEMAS ( LOGIN, SISTEMA, PERFIL, DATA )
SELECT Replace((Left([dbo_BACKUP_ACESSOS.LOGIN],255)),[PREFIXOS_E_SUFIXOS]![Valor],"") AS LOGIN, dbo_BACKUP_ACESSOS.SISTEMA, Left([dbo_BACKUP_ACESSOS.PERFIL],255) AS PERFIL, dbo_BACKUP_ACESSOS.DATA
FROM dbo_BACKUP_ACESSOS
WHERE (((dbo_BACKUP_ACESSOS.SISTEMA)<>[SISTEMAS_EXCLUIDOS]![Sistema]) AND ((dbo_BACKUP_ACESSOS.DATA)="2014-03-23"));

The thin is that this keeps asking me to enter the parameter value for "PREFIXOS_E_SUFIXOS!Valor" and for "SISTEMAS_EXCLUIDOS!Sistema"

View 6 Replies View Related

Access Sql Replace Statement Null/empty Strings

Jul 31, 2007

Im trying to concatenate a bunch of fields (50 arghh) which each are either blank or just contain one letter. This was someone elses setup for an attendance register which I think is an odd way of doing it. I would have used one field and then to get the mark for a week take a substring at the appropriate position. Anyway im trying to replace an empty string field with a letter to represent the register hasn't been marked using sql statement:

SELECT [400 Student Marks].acad_period, [400 Student Marks].student_id, [400 Student Marks].register_id, [400 Student Marks].register_group, Replace([1],"","U") AS attendance
FROM [400 Student Marks];

[1] being the first register week then I would have concatenated with [2] etc...

This however causes an error each time on the attendance field so im guessing replace doesn't work on empty strings. Is there a way round this/alternative.

Thanks for any advice.

View 1 Replies View Related

Crosstab Null Value Help

Sep 16, 2004

What's up?

I have a crosstab query with which i need help. The query takes all of the individual sales from 94 on and sorts them into total sales by year (the past 5 years 1999-2004) for each customer. After that, you can break the total sales for each customer down to the total sales for each category of product for the past 5 years. For example, you have ABC Co. that bought $20,000 last year total and bought $5,000 of category EN, 10,000 of category PS and 5,000 of category DS. My problem is that if ABC bought 5,000 in 2003 of EN but nothing of EN in 2004, the null value of 2004 does not appear as a zero, but as a blank. This obviously screws up my calculations and i need to know how to replace a null (blank) value with a zero. PLEASE HELP!!!!

if u need any more info i'll be happy to oblige.

thanks

View 1 Replies View Related

Crosstab With Null Values

Aug 9, 2005

I currently have a crosstab query that compares data for two years. The results look like this.

month 2004 2005
January 98% 95%
.....
Decemeber 98

What I am getting at is that the query returns null values for the fields that do not have data recorded for the months in 2005 because we have not reached them yet. Is there a way for me to make sure that at least the value 0 is entered in the null value areas?

View 2 Replies View Related

Null Values In Crosstab Queries

Apr 24, 2006

Hi there, instead of blank fields in my crosstab query, and hence my report, i would like a standard comment, such as 'No Booking'.

My crosstab is something like this:

.........A...........B..............C............. D
1.......X

2.......X..........................X

3...................X............................. .X

(Ignore the dots, obviously)

Currently, when i try to open the report based on this query, it fails unless each column has data in it for at least one record.

I've tried using the Nz function but haven't been able to make it work. Thankyou in advance! :)

View 5 Replies View Related

SQL: Replace Null Values With Blank ""

Aug 2, 2007

Hi everyone,

I have a a table called [Email Database] with many fields

I need to create a query that replaces all Null values with blanks or ""

I'm not that familiar with SQL so any help would be appreciated!

View 1 Replies View Related

Crosstab Query Based On Crosstab??

Sep 21, 2007

Hi all, I am utterly unsure if what I want to do is even possible:

I have two crosstab queries, qryRewCOCredit and qryWrapCOCredit which show the changeover (CO) times for the specified machine when they are NOT zero. (all zero entries don't show up).

There are many cases when there is a CO for the Rewinder on a specific day, but not for the Wrapper, and vice versa.

I want to make another crosstab query which performs a calculation. To keep it simple:

If (RewCOCredit>WrapCOCredit) Then
5-RewCOCredit
Else 'WrapCOCredit>RewCOCredit
5-WrapCOCredit

Please help!!!

View 2 Replies View Related

Query With Is Null Returning Not Null Records

Apr 18, 2006

Hello all,

A bit of a weird one, I've got a query and the criteria for showing records is that one particular field is null. However the query is showing records with the values in the field chosen for the Is Null.

Not sure why this is happening, has anyone come across this problem before?

Thanks.

View 4 Replies View Related

Replace In Query

Dec 14, 2006

Hi Guys,

Need a little bit of help, I have a report I pull out of an inhouse system with sales, shortages etc. I want to use a query to alter the formatting slightly and append it in to a different table. Most of this i can do fine, except for one thing.

Two of the sales fields in my report I'm uploading come out in the following text format:
19.0PC
27.0PC
45.0PC
etc...

I need to change this before appending as its going in to a number field, all i need to do is lose the PC, e.g.
19.0
27.0
45.0
etc...

I can do this manually, it's a simple find and replace in excel before uploading, gowever I want to automate this as much as possible. Looking around I'm pretty sure it can be done in a query using the REPLACE function but I'm unsure on the formats to use.

The only other thing is once its converted even though it will visually be a numbe (e.g. 45.0) it will still technically be a text field, will this prove a problem on the appending?

Many Thanks

Paul

View 1 Replies View Related

Replace All Query

Aug 14, 2007

Hi, i have a table of data, with a user name, and a task.

Each user is assigned many tasks, i and i would like to create a query that replaces all instances of a certain name with another name. How would i do that?

Thanks

Sean

View 1 Replies View Related

Replace Function In A Query

Jan 19, 2008

Can the replace function be used in a query?

I have used this

=Replace(Format([SITELATSEC],"00.0"),".",",") in a report and it works fine.

I have the following expression in a query that is output to a report.

LAT: "Latitude: " & [SITELATDEG] & "º " & [SITELATMIN] & "' " & [SITELATSEC] & """ "

I need to be able to display [SITELATSEC] with a comma instead of a decimal point. I tried

LAT: "Latitude: " & [SITELATDEG] & "º " & [SITELATMIN] & "' " & =Replace(Format([SITELATSEC]00.0"),".",",") & """ "

and got an error message about too many commas.

On a more general note: Has anyone ever actually finished a database - ie got to the point where no changes needed to be made? 18 months after this started, and I'm still tryng to accomodate what my manager wants!

View 3 Replies View Related

Edit Replace Tables In Query??

Jul 6, 2005

Is there a way to edit/replace tables in a query after you've copied the query? Basically, I have created a query and would like to copy the quesry. However, I would like to easily change some of the tables within the query. Is there a way to edit/replace the tables?

Thanks

View 2 Replies View Related

Find And Replace Query Or Macro

Dec 3, 2007

ne1 help me with a find and replace query or macro. What I'm trying to do is shorten the path to external PDF files after I inport them into field TxtPDFPath.

Example; after inport of files path reads
c:w2kdatapdffiles2005somepdf.pdf
c:w2kdatapdffiles2005januarysomeother.pdf
c:w2kdatapdffiles2006another.pdf

I would like to shorten all imported paths to
pdffileswhatever

Example;
pdffiles2005somepdf.pdf
pdffiles2005januarysomeother.pdf
pdffiles2006another.pdf
and so on

View 13 Replies View Related

Modules & VBA :: How To Replace Some Values From Another Query

Dec 6, 2013

I would like to replace missing TRP information from Query LF with average TRP information coming from Query LF_Average.

Somehow it doesn't work.

Code:
Public Sub Replace()
Dim strSQL7 As String
Dim qdf7 As QueryDef
strSQL7 = "SELECT LF_QUERY.*, LF_AVERAGE.Average_TRP_EUR " & _

[Code] .....

View 14 Replies View Related

Query For Find And Replace Function?

May 16, 2012

How do you use a query for the find and replace function???

View 7 Replies View Related

Update Query - Replace Function Problem

Oct 31, 2004

I'm having problems with an assignment in an online course I am taking.

The assignment is to create one Update Query to find & remove typos in a field. Specifically, the typos are multiple f's & g's embedded in a field.

I created an Update Query that finds the typos & removes just the f's. I'm having trouble with the syntax to also remove the g's.

This is what I have so far that works great.

Update: Replace([Field2],"fff","")
Criteria: Like “*fff*”
or: Like “*ggg*”

The Query finds the records that contain both the "fff" & the "ggg" typos but I'm having trouble with Syntax for removing both.

Does anyone know what I have to change in the "Update:" line to include removing the g's?

I know I could easily create 2 Querys to remove the f's then the g's but the assignment requires only 1 Query to remove both.

Thanks,
Yaani-Mai

View 5 Replies View Related

Queries :: Replace Function In Query With Sub Table

Feb 14, 2014

I am running a query for an apparel manufacturing facility. In my query I have a table called 'OrderForm' which is where the orders are put in. There are more than one type of fabric that can be a part of an apparel item, so as a result, there are multiple fields pulling from the 'FabricType' table. In order to get this to work in my query I created 'SubTables' for the different fabric fields. For example, I have tblFrontfab, tblbackfab, tblsleevefab, and tblcollarfab which are just extra copies of the 'FabricType' table. The actual question is that when I want to replace characters like ,./& in the fabric field but I can't use the replace function. It says that it is too complex to calculate.

I used this notation
Frontfab: Replace([tblFrontfab].[fabric],".","")
and the error was that it is to complex to evaluate.

View 1 Replies View Related

General :: Update Query To Replace Letters And Digits

Feb 27, 2015

We have a field of 7m records of varying length, some of which are numbers, some just letters, some alphanumeric, and most which include a dash, space or some sort of punctuation mark.

We need to replace all letters with "L", then replace all digits with "@".

We can replace characters individually using this update query:

Replace([Ref Digit Or Letter],"A","L")

But would like to use wildcard searches to resolve this, something like (these don't work!)...

Replace([Ref Digit Or Letter],"A-Z","L")
Replace([Ref Digit Or Letter],"LIKE [*A-Z*]","L")

View 13 Replies View Related

Queries :: Update Query To Replace Number With Text

Apr 15, 2014

I've made a simple form to Login/Logout with radio buttons but the buttons only allow me to push a number as a value, in my case 1 or 2 for Login or Logout.

How would I make an update query to change those numbers to the equivalent text? Or is that not possible in the same field because that is 2 different data types?

View 5 Replies View Related

Queries :: Update Query To Replace All Data In Field

Apr 8, 2013

Is it possible for an update query to simply replace all the data in a table's field with the results from a query?

For example, I have Table A with the field Years. This table performs various calculations within based on the field Years.

I would like an update query that simply replaces the Years field data in Table A with a new set of years based on a query's search criteria.

When I run the below query, I get an error saying the query must be updateable- but Im not trying to update the query, rather the Table

I've attached a photo ......

View 1 Replies View Related

Blank Fields In Crosstab Query Based On Previous Query

May 31, 2006

:confused:
I am trying to help someone with a complex problem (so it seems to me) but I will first ask about what should be a simple thing....

First goal: to COUNT the number of times a TYPE of visit is made.
There are several different TYPEs but only interested in tracking 2 of them.

When a crosstab query is created - if one of the 2 parameters are not "met", a blank is returned. I have been reading posts about using NZ and IIf IsNull, etc to get past that - but none of them make any sense to me and the Access help suggestions do not work. Hope someone can make it clear with this information: (can't give more specifics to keep privacy intact)

The SQL was written by Access not by me. :)

Here is an example of the Crosstab SQL (which is using a previous query):

TRANSFORM Count([qryTest2.TYPE]) AS CountOfTYPE
SELECT qryTest2.CID
FROM qryTest2
GROUP BY qryTest2.CID
PIVOT qryTest2.TYPE;

-----------
qryTest2 SQL: (Grouping by to remove dups)

SELECT DISTINCTROW tblM.CID, tblM.[M#], tblM.LNAME, tblM.FNAME, tblM.YMDBIRTH, tblC.ClDOS, tblC.TYPE
FROM tblM LEFT JOIN tblC ON tblM.[M#] = tblC.[M#]
GROUP BY tblM.CID, tblM.[M#], tblM.LNAME, tblM.FNAME, tblM.YMDBIRTH, tblC.ClDOS, tblC.TYPE
HAVING (((tblC.TYPE)="Out" Or (tblC.TYPE)="In"))
ORDER BY tblM.CID, tblM.LNAME, tblM.FNAME;

Thanks for you time! :)

View 1 Replies View Related

Queries :: Query Error When Data Changes In Crosstab Source Query

Aug 12, 2014

I have a database which among other things records how jobs are received i.e.: Telephone, Email, Mail, Facsimile or Web.For each client I want to identify the percentages of each method of receipt against the total of jobs received and during different time periods.I have created a make table query for all jobs received between variable dates for a client entry of the name of the client and the start and finish dates are required to run the query.

I have a crosstab query set up to count each method of receipt and a final query to work out the percentages using the total from the crosstab query fields divided by the total of all methods.I have a macro set up to replace the table with new data when I want the stats for a different client between new dates, therefore the different methods of receipt may vary for the less active clients i.e.: they may only have telephone and email .

My problem is if I choose a client where we have not received a job by a particular method (say web or facsimile), the last query working out the percentages has fixed names to cover each method but naturally produces an error when it cannot find a corresponding method of receipt. I have experimented with NZ() without success.My question is can I either have preset standard names of the column field in a crosstab query? Alternatively in the query calculating the percentages, can I include code to ignore a non-existent field in the crosstab query.

View 9 Replies View Related

Queries :: Extract And Replace With Additional Data Append Delete Query

Jul 1, 2015

I have a Table1 served by Form1..It is a list of: UnqID, process, quantity, totaltime(in seconds).I want to click on a record to bring up a filtered Form2 with the chosen record on it.What I want to be able to do is to now split the quantity (and the time) and put these new records back into Table1 and delete the original record

EG

ID1,10,write a report,2400

I want to delete this and replace it with two (or three/four etc) replacements, but still adding up to 10 quantity and 2400 seconds so that the new data could be:

ID2,5,write a report,1200
ID3,5,write a report,1200

My initial thoughts are to create a holding table to:Append filtered data on Form2 to a holding Table1hld (i don't know how to do this) delete data in Table1.then enter the new quantities into a holding Table2 (that I will input myself) and then append (through a series of queries back into Table1).The first problem is how to append (and subsequently delete) the filtered record from Form2 to Table1hld.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved