Hi There,
I have created a simple database with the below make up. Link File (Table) to excel spreadsheet which will be updated monthly with a new rolling 12 month forecast. Market intelligence (product code, quantity, country and month) is uploaded into a separate table [Country Load Template]. I then run a query to consolidate the information in [Country Load Template] to group by product code and month. This is to see for each product code by month, what is the total requested quantity. Once I have this information, I then need to calculate the consolidated quantity as a % of the forecast (link excel file) where code and month match.
I've used nested ifs for this but due to limit and having to hard code the dates this is not idea/working. We tried the Case statement but could not get it to work for us. Any help greatly appreciated. Below is nested if code: - SELECT [MI Consolidation Query].Code, [MI Consolidation Query].Qty, [MI Consolidation Query].Mth, IIf([MI Consolidation Query].Mth="009/2015",Nz(Round(([MI Consolidation Query].Qty/[EMEA Forecast].[009/2015]),4)*100),IIf([MI Consolidation Query].Mth="010/2015",Nz(Round(([MI Consolidation Query].Qty/[EMEA Forecast].[010/2015]),4)*100),IIf([MI Consolidation Query].Mth="011/2015",Nz(Round(([MI Consolidation Query].Qty/[EMEA Forecast].[011/2015]),4)*100),IIf([MI Consolidation Query].Mth="012/2015",Nz(Round(([MI Consolidation Query].Qty/[EMEA Forecast].[012/2015]),4)*100),IIf([MI Consolidation Query].Mth="001/2016",Nz(Round(([MI Consolidation Query].Qty/[EMEA Forecast].[001/2016]),4)*100)))))) AS [% OF EMEA Forecast], IIf([% OF EMEA Forecast]<3,"Order",IIf([% OF EMEA Forecast]="#Div/0!","Load","Load Fcst")) AS [Output 1], IIF([Output 1]="Order","Order","Load Forecast")
-
FROM [MI Consolidation Query] INNER JOIN [EMEA Forecast] ON [MI Consolidation Query].Code = [EMEA Forecast].Parent
-
WHERE ((([MI Consolidation Query].Code)=[EMEA Forecast].[Parent]));
1 1879
In SQL, the Select Case functionality is provided through the Switch() function. So just redoing that one field, you would get - Switch([MI Consolidation Query].Mth = "009/2015", Nz(Round(([MI Consolidation Query].Qty/[EMEA Forecast].[009/2015]),4)*100)
-
, [MI Consolidation Query].Mth="010/2015", Nz(Round(([MI Consolidation Query].Qty/[EMEA Forecast].[010/2015]),4)*100)
-
, [MI Consolidation Query].Mth="011/2015", Nz(Round(([MI Consolidation Query].Qty/[EMEA Forecast].[011/2015]),4)*100)
-
, [MI Consolidation Query].Mth="012/2015", Nz(Round(([MI Consolidation Query].Qty/[EMEA Forecast].[012/2015]),4)*100)
-
, [MI Consolidation Query].Mth="001/2016", Nz(Round(([MI Consolidation Query].Qty/[EMEA Forecast].[001/2016]),4)*100)
-
) AS [% OF EMEA Forecast]
While working this out, I noticed that you aren't providing any of your Nz() functions with a value to return if your statements are Null. Also, I'm pretty sure that if your Qty field is null, then your Round function will fail before the Nz() function comes into play.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Joshua Beall |
last post by:
Hi All,
I remember reading that both nested classes and namespaces would be
available in PHP5. I know that namespaces got canceled (much sadness...),
however, I *thought* that nested classes...
|
by: platho |
last post by:
Hello,
I bounced into the max 25 columns index limits on DB2 v7.2 on NT.
Is this still so in other operating systems or in v8 ? Are there plans to
change this in the future ? Any workarounds...
|
by: Tcs |
last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't
loaded it yet. I'm still using MS Access. And no, I don't believe this is an
Access question. (But who knows? I...
|
by: Neptune |
last post by:
Hello.
I am working my way through Zhang's "Teach yourself C in 24 hrs (2e)"
(Sam's series), and for nested loops, he writes (p116) "It's often
necessary to create a loop even when you are...
|
by: Profetas |
last post by:
Hi,
Nested statements helps to generate complex source code,
what is the nesting limit that you normally consider?
I know that the Halsted and McCabe analyses can define the acceptable
level,...
| |
by: GY2 |
last post by:
I writing some documentation and I want to describe a common code structure
which is used to step through all the items in a collection (e.g. each file
in a subdirectory) while applying more and...
|
by: Fredrik Lundh |
last post by:
Patrol Sun wrote:
so why exactly are you trying to nest 20 or 100 for-in loops?
</F>
|
by: vippstar |
last post by:
n1256.pdf (C99 TC3), 5.2.4.1 Translation limits p1 says:
Does that mean that *any* program using an array of two or more
elements other than char is allowed to be rejected by an
implementation?...
|
by: Nathan Sokalski |
last post by:
I have several nested For loops, as follows:
For a As Integer = 0 To 255
For b As Integer = 0 To 255
For c As Integer = 0 To 255
If <Boolean ExpressionThen <My CodeElse Exit For
Next
If Not...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |