Assign value to cell in column depending on name of column - matrix - sql-server-2008

I have a matrix that dynamically displays columns and rows. (dûh)
I will always have a (dynamic) column with the name 'Everyone'.
Now I am looking to color those cells green that have value > 0 AND columname 'Everyone'
I think I should be doing something with a IIF statement but how do I find the name of the column for a specific cell?
Thanks for thinking with me!
Henro

You can check if a column is in scope of a group (a column/row group) using an InScope expression - you should be able to do this on the background colour expression of the offending cell
How is the column defined? Is it using a grouping or are you adding a static column using the advanced editor? Either way you should be able to use the InScope function to check if the cell belongs to a certain column
e.g.
=iif(someColumn.Value > 0 AND InScope("ColumnGroup"), "Green", Nothing)
Give a bit more info on the groups/layout and I might be able to help a bit more

Related

Automatic Replace "0" with blank cell

I have a sheet called "Test". Column B shows dynamic API calls, then I use a macro to copy all cells from Column B to Column C every 1 hour in order to store those prices, however sometimes API call fails, so it shows 0. I want to mass replace all cells containing "0" (match exact case) from all columns of sheet "Test" without changing Column B (which is the column for the API calls so we don't want to change its formula).
How can I do that?
Thank you!
Google sheets doesn't have this function yet but this could do the trick:
Select all cells (Ctrl + A) click Format > Conditional Formatting
Use the dropdown to select Equal To and type 0
Tick the text tickbox and change the text color to white, this will
effectively hide all your zero values.
You can define a format as
0;-0;

Do I need a script or a formula?

I am trying to have the formula look in Column A for not empty cells. (That part of the formula works fine.) Then return the name from Column B that's in the same row as the not empty cell.
Column A Column B
text/date Kelly
So if B has anything in it, tell me the name Kelly. I 've tried combining formulas, but I'm either not doing it correctly or maybe I need a script?
Here's the part that's working: =IF(A24="","don't meet","meet")
Of course, I want it to search the whole column, but I know for sure 24 has the text in the cell with a name so I was just playing around that line.
Answer is based on the description and document you provided and should give you something to work with.
This formula simple checks the entire Column A and returns values from the corresponding row from Col B if the Cell from the Col A row is empty/blank.
=ARRAYFORMULA((IF(A1:A<>"",B1:B,"")))
Here are example screenshots of your example data + end result
Though I'm not entirely sure what you'd like to happen if A has values on them. This formula retains A if it has content but you could always change the (A2:A="",B2:B,A2:A) part of the formula if you want something else to happen if A is not empty.
Give this a try, I put it in your sheet in the green area.
=ARRAYFORMULA(IF(A1:A15 = "", "", B1:B15))
Arrayformula applies the IF function to the entire range. So substitute A1:A15 with what ever the whole range is, A1:A600 or A1:A if you want to do the whole column. Make srue the second column has the same values but with B.
You can use filter() to filter your Column B if both column A and column B is not empty.
Formula:
=filter(B1:B,A1:A<>"",B1:B<>"")
Output:

SSRS - Display a text based on first row value

I am trying to write an expression, If the result-set's first row values is equal to 1 then display a text. I am not sure how to get first rows value. Can someone help me out to achieve the same.
=IIF(Fields!IsAccessAvailable.Value=1, "You have full access to this page","")
=IIF(First(Fields!IsAccessAvailable.Value, "YourDatasetName")="1",You have full access to this page","")
You could also add the same expression as Textbox Visibility, so that if Fields!IsAccessAvailable.Value = 1 then and then only this textbox will be shown else it will hide it.

(SSRS) if cell contains specific text then divide another cell by a number say 2

I'm having trouble trying to divide a cell by (A NUMBER) only if another cell contains specific text and if the cell contains another text i want it to be divide by a different number in SSRS
This is what i have but it is not working.
=IIF(Fields!PARTNO_LOT.Value=("A1001"),Fields!LOCSTOCK.Value/200)
I have added a example but in excel just to show my intent in SSRS.
If the above answer doesn't work, try this:
=Switch(
Fields!PARTNO_LOT.Value="A1001",Fields!LOCSTOCK.Value/200,
Fields!PARTNO_LOT.Value="A1002",Fields!LOCSTOCK.Value/285,
Fields!PARTNO_LOT.Value="A1003",Fields!LOCSTOCK.Value/89
)
Let me know if this helps.
If I understand correctly, you are trying to execute multiple conditions. You can use nested IIF statements:
=IIF(Fields!PARTNO_LOT.Value=("A1001"),Fields!LOCSTOCK.Value/200,
IIF(Fields!PARTNO_LOT.Value=("A1002"),Fields!LOCSTOCK.Value/285, Fields!LOCSTOCK.Value/89))
If your values are only few, this would work. If they are more than 2-3, I would look into creating a function. Reference: https://msdn.microsoft.com/en-us/library/ms156028.aspx

How to get the max of a sum?

Can anyone tell me how do I get the Max of a calculated field? Below is an image of my situation:
Note that Flag is of type int.
I want to write the expression in the image , but when I use it, it kinda does:
Sum(Sum(Fields!Flag.value))
Can anyone help me out on this. I think I need to add scope for the Sum(Flag) but when I add the group scope as EMPID as:
=iif(SUM(Fields!Flag.value,"Fields!EmpID.Value")>2,"RED",nothing)
It throws me an error saying something about the scope.
EDIT:
I need attendance of each employees. FLAG is basically 1 if absent and 0 if anything else.
The bottom row(Flag,Date,Status,Comment). Now I have an alert There:
=iif(Fields!Flag.Value=1,"RED",Nothing)
Beside the Textbox(Textbox62) in middle row(EmpID,EmpName) I did Expression:SUM(Flag) and in the Fill section in Text Box Properties i have done:
=iif(SUM(Fields!Flag.value,"Fields!EmpID.Value")>2,"RED",nothing)
So the above expression creates an alert if employee is absent more than 3 days.
The top most row(Department,Manager) can be drilled down for to see more detailed view of the report. Now my problem is, in the column (FLAG) i need to create a Background color change if any employee in a particular department is absent more than 3 days.so that we do not have to drill down all the departments in order see if any employee is absent or not.
So my approach was to see the Max(Sum(Flag))>2 then create color change. I tried:
=iif(MAX(Sum(Fields!Flag.Value))>2,"Red",Nothing)
It does not work at the Department level as it basically considers (SUM(Sum(Flag))).
Thanks................
If you don't specify the scope of an aggregate, it is assumed that you are using the current scope. For example, when you say
Sum(Fields!Flag.value)
It is interpreted as something like
Sum(Fields!Flag.value, "EmpID")
The scope is the name of the Group, not the name of a dataset field.
Depending on where it is in the table. When you want to say something like
Sum(Sum(Fields!Flag.value))
You need to specify the scope for each one that isn't going to be the current default.
In your case you should use something like this:
=iif(MAX(SUM(Fields!Flag.value, "EmpID"), "Department")>2,"RED",nothing)
Again, pay attention to which group each aggregate is referring to and where the expression is on the table.
Also, this expression in a textbox will just make the word "RED" appear in the box. If you want it to change the color, you have to put it in the "Fill color" expression in the properties.