textrun error expression expected - ssrs-2008

Hello I am running the following expression in a textbox and getting the error below. I've used the same expression in other text boxes and it's working fine so am very confused as to why it's not working in this one.
=sum(IIF(Fields!Fieldname1.Value = "A" and Fields!Fieldname2.Value = "Red", Fields!Total.Value, Nothing)) / 1675 * 100 OR =sum(IIF(Fields!Fieldname1.Value = "A" and Fields!fieldname2.Value = "Blue", Fields!Total.Value, Nothing)) / 1702 * 100
The Value expression for the textrun ‘Textbox278.Paragraphs[0].TextRuns[0]’ contains an error: [BC30201] Expression expected.

Ok managed to answer my own question, didn't need the '=' before the 'sum'
=sum(IIF(Fields!Fieldname1.Value = "Red" and Fields!Fieldname2.Value = "Red", Fields!Total.Value, Nothing)) / 1675 * 100 OR sum(IIF(Fields!Fieldname1.Value = "Blue" and Fields!Fieldname2.Value = "Blue", Fields!Total.Value, Nothing)) / 1702 * 100

Related

Mismatched Input-Ternary Operator (PineScript)

On using ternary operator in Plotchar() , the true condition is not fully recognized (in spite of placing it in "()" brackets). Mismatched inpur error is given(refer image).
How to resolve this ?
Code:
k = ta.sma(...)
plotchar((k < 20) ? (xUp , "Go Long", "▲", location.bottom, color.lime, size = size.tiny) : na)
Image:
The ternary operator uses the series (xUp : na) only for conditionals,not the entire plotchar parameters.
k = ta.sma(...)
plotchar(k < 20 ? xUp: na , "Go Long", "▲", location.bottom, color.lime, size = size.tiny)

Convert/Split string to array at letter

I know there are a lot of other threads for splitting a String by a specific separator or position. I have a little bit different case and couldn't find any similar question here.
My input string is:
"A 300 133 Z 800 900 12 50 Q 3 -10 X"
and the desired output is:
[["A", "300", "133"], ["Z", "800", "900", "12", "50"], ["Q", "3", "-10"], ["X"]]
First, let's separate each elements:
let inputString = "A 300 133 Z 800 900 12 50 Q 3 -10 X"
let elements = inputString.components(separatedBy: .whitespaces)
Then, we can use reduce(into:_:): we iterate each element of the array. If it's a letter, we append it as a new sub array, if not, we append it to the last sub array.
let reduced = elements.reduce(into: [[String]]()) { result, current in
guard var last = result.last,
current.rangeOfCharacter(from: .letters) == nil else {
result.append([current])
return
}
last.append(current)
result[result.count - 1] = last
}
Side note:
I used the test "is letter": "has a letter", so if you have "333D", it will return "true". The test there is to update according to your needs, I don't check if there is only one letter (as in your example, etc).

SSRS - Conditional formatting not getting applied?

I have the following expression to apply background colour to a text box but only the red colour is getting applied when that condition is true. All the other conditions are showing up as white? For example when the first condition is true when the report renders, the background colour is white instead of green?
=IIF(Round(SUM(CInt(Fields!TotalAchieved.Value) * 7.14)) >= 86, "Green",
IIF(Round(SUM(CInt(Fields!TotalAchieved.Value) * 7.14)) >= 79 AND
Round(SUM(CInt(Fields!TotalAchieved.Value) * 7.14)) <= 85, "Light Green",
IIF(Round(SUM(CInt(Fields!TotalAchieved.Value) * 7.14)) >= 64 AND
Round(SUM(CInt(Fields!TotalAchieved.Value) * 7.14)) <= 78, "Yellow", "Red" )))
It would seem that your SUM(CINT(Fields!TotalAchieved.Value) * 7.14) calculation is not giving you the results you expect . The first thing I would do is add a column that shows this value to make sure that it's gives you what you expect.
Once you have that correct then I would also suggest that you use a SWITCH statement rather than nested IIFs, they are much easier to read/debug.
You expression would be
=SWITCH(
Round(SUM(CInt(Fields!TotalAchieved.Value) * 7.14)) >= 86, "Green",
Round(SUM(CInt(Fields!TotalAchieved.Value) * 7.14)) >= 79, "LightGreen",
Round(SUM(CInt(Fields!TotalAchieved.Value) * 7.14)) >= 64, "Yellow",
TRUE, "Red"
)
This way you don't need to check for ranges as, for example, if the value was 75, the 1st expression fails but the second one is true so SWITCH will stop at that point and not evaluate the rest, if all fail then the final TRUE will act like an else.

AWS DynamoDB Query with start and end value

I am trying to perform a query where I want to retrieve all the items that have height and width between 2 defined values like this:
let queryExpression = AWSDynamoDBQueryExpression()
queryExpression.filterExpression = ":widthSmall < #width < :width AND :heightSmall < #height < :height"
queryExpression.keyConditionExpression = "#addedByType = :addedByType"
queryExpression.expressionAttributeNames = ["#addedByType": "addedByType", "#width": "widthSmall","#height": "heightSmall","#width": "width","#height": "height"]
queryExpression.expressionAttributeValues = [":addedByType": "APPUSER", ":widthSmall": 50, ":heightSmall": 50, ":width": 100, ":height": 100]
queryExpression.scanIndexForward = false
queryExpression.limit = 200
This though throw the following error because of the expressionAttributeNames
fatal error: Dictionary literal contains duplicate keys
What would be the correct way to check so ?
Ok so after quite a bit of trial and error I have figured out what I was doing wrong and came with the following result:
queryExpression.filterExpression = ":widthSmall < #width1 AND #width < :width AND :heightSmall < #height1 AND #height < :height"
queryExpression.keyConditionExpression = "#addedByType = :addedByType"
queryExpression.expressionAttributeNames = ["#addedByType": "addedByType", "#width1": "width","#height1": "height", "#width": "width", "#height": "height"]
queryExpression.expressionAttributeValues = [":addedByType": "APPUSER", ":widthSmall": 50, ":heightSmall": 50, ":width": 101, ":height": 101]
The problem was that I was referencing twice the same key in the dictionary

Crystal Reports select expert OR statement on CSV

I am using the Select Expert to filter on a combination of 3 fields:
({flatfile_csv.site} = "L" and {flatfile_csv.bursguar} = "1")
or
({flatfile_csv.site} = "L" and {flatfile_csv.bursnorm} = "1")
In this case it only matches:
({flatfile_csv.site} = "L" and {flatfile_csv.bursguar} = "1")
If I swap the statements around:
({flatfile_csv.site} = "L" and {flatfile_csv.bursnorm} = "1")
or
({flatfile_csv.site} = "L" and {flatfile_csv.bursguar} = "1")
Then it only handles
({flatfile_csv.site} = "L" and {flatfile_csv.bursnorm} = "1")
It seems to completely ignore the second part of the OR statement. Any idea how to implement an OR in CR?
I've never used CR with a CSV file before, so I don't know how it's handling those empty strings. Try setting the selection formula to "Default Values for Nulls" instead of "Exception for Nulls" with this:
{flatfile_csv.site} = "L"
and
(
{flatfile_csv.burnsnorm}="1"
or {flatfile_csv.burnsguar}="1"
)