简体   繁体   中英

(Excel 2013/Non-VBA) Format Data column based on value of another cell?

We have a column that is query driven, and the query partially formats the values in the column using math based off the value of a "user entry cell" on another sheet.

For the really curious, our query looks like this:

DECLARE @rotationsNum INT
SET @rotationsNum = ?
SELECT  t.Piece_ID, t.Linear_Location, ((ROW_NUMBER() OVER(ORDER BY 
Linear_Location) -1 )%@rotationsNum )*(360/@rotationsNum) AS Rotation FROM 
(SELECT Position.Feature_Key, Piece_ID, ((Place-1)%(Places/@rotationsNum))+1 AS Linear_Location, Place, Measured_Value, Places FROM Fake.dbo.Position LEFT JOIN Fake.dbo.Features 
ON Position.Feature_Key = Features.Feature_Key WHERE Position.Inspection_Key_FK = (SELECT Inspection_Key FROM Fake.dbo.Inspection WHERE Op_Key = ?)) AS t 
ORDER BY Piece_ID, Linear_Location

The first parameter "@rotationsNum" is a cell that will always have a value between 1-4. IF the value is 1, the entire column will show "0"s, which we want to show as "N/A". However, it isn't as simple as "How to hide zero data.." Because if the "@rotationsNum" == 2, 3, or 4, there will still be 0 values in the column that need to be shown.

A "@rotationsNum" value of 2 will have the query write the column as such: example

So I am trying to come up with a way to format the column =IF(cell>1, do nothing, overwrite entire column to say "NA"). But I don't think it is that straight forward since the column is query driven.

My resolution was to format the column so that if the cell that drives the "@rotationsNum" parameter is below 2, then the whole column just gets "grayed out". It kind of makes it look like a redaction, and isn't as desirable as "NA", but it works for our purposes. Hopefully this solution helps someone else who stumbles upon this problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM