Summing Only Visible Rows in SSRS - ssrs-2008

I'm trying to sum only the visible rows for a report and I know the format is:
=Sum( iif( <use the condition of the Visibility.Hidden expression>, 0, Fields!A.Value))
In my report, I've set row visbility to:
=IIF(CInt(Fields!EM_ET.Value)=1 Or CInt(Fields!EM_ET.Value)= 2,True,False)
Not exactly sure what I'm missing, but when I use this as an expression:
=Sum(IIF(CInt(Fields!EM_ET.Value)=1 Or CInt(Fields!EM_ET.Value)= 2,True,False),0,Fields!EM_ET.Value)
I get this following error: Value expression for textrun'FTD1.Paragraph[0].TextRuns[0]' has a scope argument that is not valid for aggregate function.

You are giving the True/False as output to the SUM() from your expression.You need to change your expression as,
=Sum(IIF(CInt(Fields!EM_ET.Value) = 1 Or CInt(Fields!EM_ET.Value)= 2,0,Fields!EM_ET.Value))

Thanks coder of code.
I am getting some error message if i am using '0', so i replaced with nothing it's working. I thought it would be helpful.
=SUM(IIF(ISNOTHING(Fields!value1.Value) OR ISNOTHING(Fields!value2.Value),NOTHING,Fields!value1.Value))

I was having similar issues. I know this question has a marked answer, however it isn't entirely correct.
The following contains the code from the "marked correct" answer:
=Sum(IIF(CInt(Fields!EM_ET.Value) = 1 Or CInt(Fields!EM_ET.Value) = 2,0,Fields!EM_ET.Value))
The following snipit of code contains the code from above, with a slight tweak:
=Sum(IIF(CInt(Fields!EM_ET.Value) = 1 Or CInt(Fields!EM_ET.Value) = 2,NOTHING,Fields!EM_ET.Value))
By changing the "0" to "NOTHING" this will resolve any lingering issues with your formula. The formula I was having issues with was returning "#Error" in the cell that was supposed to return the sum of the visible cells in the column within the row group.
My formula originally looked like this:
=IIF(Sum(Fields!VCBitType.Value) <> 0 OR (Parameters!Details.Value = "Detail"), Sum(IIF((Fields!VCBitType.Value = 0) and (Parameters!Details.Value = "Dangerous"),0,Fields!VC.Value)), "")
I altered my formula after seeing Hari's comment above:
=IIF(SUM(Fields!VCBitType.Value) <> 0 OR (Parameters!Details.Value = "Detail"), SUM(IIF((Fields!VCBitType.Value = 0) and (Parameters!Details.Value = "Dangerous"),NOTHING, Fields!VC.Value)), "")
I wanted to set the cells value to "" (empty) rather than hide the cell entirely or set that cell's value to "0" in my report (due to the fact that not displaying the cell entirely made the report look really funky). Because I did this, using a "0" in my formula conflicted with the value of the cell which was "" (empty), causing the formula to break. The only change I made was to alter "0" to "Nothing", this resolved the issue I was having with the cell's formula.

Related

If the hour is >=19 or <=8 then return a value "OOH" if its not within that range return "OPEN"

I have the formula
=IF(AND(HOUR(D2)<=8,HOUR(D2)>=19), "OPEN", "OOH")
This should return the required text values "OPEN" or "OOH" depending if the hour falls within the noted range.
When trying in cell E2 of this sheet https://docs.google.com/spreadsheets/d/1xNFVHLnQGkRgZdLmejCyU0BByOPBY8NMoIYj6SkTFGY/edit#gid=431567503 it returns a text value but not always the correct one. What could be missing from this formula?
I have also tried swapping the range around without success
=IF(AND(HOUR(D2)>=19),HOUR(D2)<=8, "OPEN", "OOH")
Update: also tried with OR instead of AND but it does no better
=IF(OR(HOUR(C3) >=19, HOUR(C3) <=8), "OPEN", "OOH")
if from 8 to 19 = OPEN then use this in E2:
=INDEX(IF((HOUR(C2:C)>=8)*(HOUR(C2:C)<19), "OPEN", "OOH"))
Your conditions are a bit wrong. The IF form is:
=IF(condition, value_if_true, value_if_false)
In your question, you say hour >=19 OR hour <= 8, so you should be using OR, as you do in your update. However, you switched the true and false values in your updated statement. Try:
=IF(OR(HOUR(C3) >=19, HOUR(C3) <=8), "OOH", "OPEN")
With 8:01, this returns "OOH"
With 9:01, this returns "OPEN"
With 18:01, this returns "OPEN"
With 19:01, this returns "OOH"
Logic error. The thing can't be <=8 and >=19 at the same time.
If you reverse the signs to >8 and <19, you might get closer to what you want.

Conditional color of Table cell in pinescript v5

I am looking to have a reference table of sorts for my tradingview set up. My aim is to compare 5 stock tickers, namely apple(AAPL), microsoft(MSFT), Amazon(AMZN), Google(GOOGL) and Tesla(TSLA). The data is current price, price change(from yesterday's) and percentage change.
Here is the screengrab of the table
https://prnt.sc/XzaN3fJjwuZz
What I am doing to do next is to color the cells based on the positive or negative changes. So if a change has been positive, the cell background becomes green, if negative, then red.
I tried using conditional logic but I am getting error: An argument of 'series color' type was used but a 'series int' is expected
I searched and could find only two questions in stackoverflow on this topic:
pine script error- An argument of 'series string' type was used but a 'const string' is expected
Converting series integer to integer in pinescript
However, I was not able to understand as to how to relate their answers to my case.
Here is the code snippet I am using to calculate the values:
pr_x2 = request.security(x1,"D", close[1])
pr_x1 = request.security(x1,"", close)
pr_diff = (pr_x1 - pr_x2)
pr_pct = truncate(((pr_diff1/pr_x2)*100),2)
where
pr_x2 -> previous day close
pr-x1 -> current value
I'm trying to use this condition for background in the cell:
table.cell(panel, 0, 1, str.tostring(pr_diff) + "\nChg: " + str.tostring(pr_pct1) + " %", bgcolor = (pr_diff>0)?color.green:color.red, text_color=color.white)
but then I get the error I have mentioned above.
I read in the discussions forum that converting series integer to integer in pinescript cannot be done. Is there a workaround for my case?
To admin: My apologies if it is similar to a previous thread, but I was not able to find it. It would be very kind of you to point me in the right direction.
You are trying on the cell, try applying on the array.
var = array.get(id) conditions ? Color.green :
array.get(id) conditions? Color.red

Remove formula from column with python

I am trying to remove the formula from a column in a existing sheet with python.
I tryed to set my formula to None using the column object (column.formula = None)
It does not work and my column object remains unchanged. Anyone have inputs to solve this issue ? Thank you !
This took me a bit to figure out, but seems like I've found a solution. Turns out that this is a 2-step process:
Update the column object to remove the formula (by setting column.formula to an empty string).
For each row in the sheet, update the cell within that column to remove the formula (set cell.value to an empty string and cell.formula to None).
Completing the STEP 1 will remove the formula from the column object -- but that cell in each row will still contain the formula. That's why STEP 2 is needed -- STEP 2 will remove the formula from the individual cell in each row.
Here's some example code in Python that does what I've described. (Be sure to update the id values to correspond to your sheet.)
STEP 1: Remove formula from the Column
column_spec = smartsheet.models.Column({
'formula': ''
})
# Update column
sheetId = 3932034054809476
columnId = 4793116511233924
result = smartsheet_client.Sheets.update_column(sheetId, columnId, column_spec)
STEP 2: Remove the formula from that cell in each row
Note: This sample code updates only one specific row -- in your case, you'll need to update every row in the sheet. Just build a row object for each row in the sheet (like shown below), then call smartsheet_client.Sheets.update_rows once, passing in the array of row objects that you've built corresponding to all rows in the sheet. By doing things this way, you're only calling the API once, which is the most efficient way of doing things.
# Build new cell value
new_cell = smartsheet.models.Cell()
new_cell.column_id = 4793116511233924
new_cell.value = ''
new_cell.formula = None
# Build the row to update
row_to_update = smartsheet.models.Row()
row_to_update.id = 5225480965908356
row_to_update.cells.append(new_cell)
# Update row
sheetId = 3932034054809476
result = smartsheet_client.Sheets.update_rows(sheetId, [row_to_update])

SSRS Expression works as cell value expression, but not as background color value expression

I have an SSRS report with a matrix in it, where I needed to display the Growth Percentage in a column group compared to the previous column value. I managed this by using custom code...
DIM PreviousColValue AS Decimal
Dim RowName AS String = ""
Public Function GetPreviousColValue(byval Val as Decimal, byval rwName as string) as Decimal
DIM Local_PreviousColValue AS Decimal
IF RowName <> rwName THEN
RowName = rwName
PreviousColValue = val
Local_PreviousColValue = 0
ELSE
Local_PreviousColValue = (Val - PreviousColValue)/PreviousColValue
PreviousColValue = val
END IF
Return Local_PreviousColValue
End Function
..and then using this as the value expression in the cell..
=Round(Code.GetPreviousColValue(ReportItems!Textbox8.Value,Fields!BusinessUnit.Value)*100,0,system.MidpointRounding.AwayFromZero)
So far so good, this produces the expected value. Now I need to use this expression in a background color expression to get a red/yellow/green but in that capacity it fails.
The background color expression looks like this: =IIF(ROUND(Code.GetPreviousColValue(ReportItems!Textbox9.Value,Fields!Salesperson.Value)*100,0,System.MidpointRounding.AwayFromZero)<=-5,"Red"
,IIF(ROUND(Code.GetPreviousColValue(ReportItems!Textbox9.Value,Fields!Salesperson.Value)*100,0,System.MidpointRounding.AwayFromZero) >=5,"Green"
,"Yellow"))
When I run the report the background color expression only ever returns yellow. As a test I pasted the background color expression in as the cell value and ran it again. Results in the image below
I get no build or run time errors so I'm not sure why this does not work.
After some more searching I found a better Custom Code solution than what I was using to get the Growth Percentage in a column group compared to the previous column value. Besides being simpler to read this version has an added benefit: You can dynamically hide the growth percentage column for your first instance of the column group (because it will always be zero or null) and still get the right values in the 2nd/3rd/4th instance of the column group.
Public Function GetDeltaPercentage(ByVal PreviousValue, ByVal CurrentValue) As Object
If IsNothing(PreviousValue) OR IsNothing(CurrentValue) Then
Return Nothing
Else if PreviousValue = 0 OR CurrentValue = 0 Then
Return Nothing
Else
Return (CurrentValue - PreviousValue) / PreviousValue
End If
End Function
The new function is called like so
=Code.GetDeltaPercentage(Previous(Sum(<expression or dataset field>),"Group ByColumn"), Sum(<expression or dataset field>))
Re: the original question - why does my cell value expression not work when used as the background color expression - I took an easy out and just referenced the cell value.
=IIF(ROUND(Me.Value*100,0,System.MidpointRounding.AwayFromZero)<=-5,"Red"
,IIF(ROUND(Me.Value*100,0,System.MidpointRounding.AwayFromZero) >=5,"Green"
,"Yellow"))

Crystal Reports print if NOT blank

OK...so there seems to be another problem now.
I have used the following code:
IF ({rmadtl.ShortChar01}) = ""
OR
(ISNULL ({rmadtl.Shortchar01}))
THEN
TRUE
for the Serial Number which is from the rmadtl table and is ShortChar01 field. This works and hides any serial numbers that are empty strings.
BUT...
IF ({rmadtl.ShortChar03}) = ""
OR
(ISNULL ({rmadtl.Shortchar03}))
THEN
TRUE
does NOT hide the Dates. It still shows "Date:" and also "0"
I am not sure why this is happening for the date field but not the serial number field. Does anybody else know why this is happening?