Null Values.........

GMFTM

New Member
Joined
Nov 4, 2016
Messages
42
I have a query that has group by's and an expresstion and 4 calculated columns. In the calculated colums I have NULLS that are returned. In these three columns I do not want to include them in the dataset if all three calculated fields are NULL or 0.

I have posted the SQL below:

SELECT [Auction Data].AuctionName,
[Auction Data].Company,
[Auction Data].Month,
[Auction Data].MY,
Count([Auction Data].Offered) AS CountOfOffered,

IIf(Sum([Auction Data].[Sale Rate])/Count([Auction Data].[Offered])<Avg([211 Offered Sold tDevMY]. SRStDevMin]),Sum([Auction Data].[Sale Rate])/Count([Auction Data].[Offered]),
IIf(Sum([Auction Data].[Sale Rate])/Count([Auction Data].[Offered])>Avg([211 Offered Sold StDev MY].[SRStDevMax]),Sum([Auction Data].[Sale Rate])/Count([Auction Data].[Offered]),Null)) AS [Sale Rate],

IIf(([Auction Data].[Sale_Price])<([211 Offered Sold StDev MY].[SPStDevMin]),([Auction Data].[Sale_Price]),
IIf((([Auction Data].[Sale_Price])>([211 Offered Sold StDev MY].[SPStDevMax])),([Auction Data].[Sale_Price]))) AS [Sale Price],

IIf(([Auction Data].[Days to Sell])<([211 Offered Sold StDev MY].[DTSStDevMin]),([Auction Data].[Days to Sell]),
IIf((([Auction Data].[Days to Sell])>([211 Offered Sold StDev MY].[DTSStDevMax])),([Auction Data].[Days to Sell]))) AS [Days to Sell]

FROM [Auction Data]
LEFT JOIN [211 Offered Sold StDev MY] ON ([Auction Data].MY = [211 Offered Sold StDev MY].MY)
AND ([Auction Data].Month = [211 Offered Sold StDev MY].Month)
AND ([Auction Data].Company = [211 Offered Sold StDev MY].Company)

GROUP BY [Auction Data].AuctionName,
[Auction Data].Company,
[Auction Data].Month,
[Auction Data].MY,
IIf(([Auction Data].[Sale_Price])<([211 Offered Sold StDev MY].[SPStDevMin]),([AuctionData].[Sale_Price]),
IIf((([Auction Data].[Sale_Price])>([211 Offered Sold StDev MY].[SPStDevMax])),([Auction Data].[Sale_Price]))),
IIf(([Auction Data].[Days to Sell])<([211 Offered Sold StDev MY].[DTSStDevMin]),([Auction Data].[Days to Sell]),
IIf((([Auction Data].[Days to Sell])>([211 Offered Sold StDev MY].[DTSStDevMax])),([Auction Data].[Days to Sell])));
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi,
you can write a second query to select from this first query:

Code:
Select * from MyQuery 
WHERE NOT (
    [Sale Rate] is null AND
    [Sale Price] is null AND 
    [Days to Sell] is null
    )
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top