Find the value smaller neighbors - mysql

I have a table:
What is the query that allows me to take the next smallest value based on what I entered?

Use your input instead of myinput:
select max(value)
from mytable
where value < myinput
EDIT:
We are filtering out all the elements, which have at least myinput value and find the maximum of the remaining elements, yielding the searched neighbour.

Related

Calculate percentage of a grouping column in SSRS

Calculate percentage of "TotalFound, NotFound"
I need to calculate the percentage of the subgroup "compare".
If you name the textboxes containing your totals, you should be able to use reportitems:
= ReportItems!FoundInCMDB_Total.Value / ReportItems!NotFoundInCMDB_Total.Value
Just select each textbox containing the totals relevant to the percentage and change the name in properties. Then in the textbox you want your percentage to appear in type =ReportItems! and a list should appear including the named textboxes.
I found an answer for the (unclear) question I've tried ask above. SSRS calculates percentage group only when you total column is inside the same group. This way you can call the total as an expression in your percentage column to do calculate %. But if the Percentage is outside your X/Y group you need to mention the group name like =((Fields!Total.Value,"X")*100/sum(Fields!Total.Value,"X"))&"%"
Thanks,
Kavin

SSRS limit axis value

I want to limit the max value of the vertical axis to 100 % and not 101%.
I have tried setting the axis limit to 100 but that did not help either. Changing that to 100.05% just changes the axis label but the line does not jump to the top of the chart. Is there a way to restrict the high value of the axis to a particular number?
Follow up question: I see this in ChartDataLabel. What does this mean =IIF(Fields!Reliability.Value >= 100, "", Fields!Reliability.Value) ?
To do what you want, while in design mode, right-click on the axis and choose Vertical Axis Properties. Set the Minimum and Maximum values to what you want.
Now, it sounds like that is something you have already tried, but didn't like the results. Another thing you can do is use the values from the data set, along with an expression, to set the min and max values for the axis. So, instead of setting the min and max values manually, you can try something like the following. This assumes the value you are charting is Fields!Reliability.Value.
Minimum: =Min(Fields!Reliability.Value)
Maximum: =Max(Fields!Reliability.Value)
If you want a little bit of a buffer above and below the value line, then you can add and subtract from those values like this:
Minimum: =Min(Fields!Reliability.Value)*0.95
Maximum: =Max(Fields!Reliability.Value)*1.05
Adjust these as desired.
To answer your follow up question about the ChartDataLabel.
=IIF(Fields!Reliability.Value >= 100, "", Fields!Reliability.Value)
This expression sets the ChartDataLabel to an empty string if the Fields!Reliability.Value from the data set is greater than 100, otherwise it uses whatever value is in Fields!Reliability.Value.
Hope this helps you out.

How do I hide a table row element based on a condition

I have a table with the fields 'TotalNumber' and 'TotalConfirmed' on each row. The row also has a Percentage field whose value is calculated in the report query, and a field with an asterisk if that percentage value is below a certain value. I want to add a summary column with sum of TotalNumber and TotalConfirmed (done), a calculation of the overall Percentage (done), and then an Asterisk in the column if the overall Percentage is below a certain value. I've tried a conditional hide on the item, using
=(ReportItems!NumConfirmed1.Value / ReportItems!NumOffenders1.Value) >= 0.65
and having an Asterisk show in the box by default, but it doesn't show for values above or below the cutoff. What am I missing?
iif(cdbl(ReportItems!NumConfirmed1.Value / ReportItems!NumOffenders1.Value)>=0.65,true,false)

Getting Value of Y-Axis Max in SSRS

I was wondering if there was anyway to set a value of a data point on a graph equal to the Max auto generated Y-Axis Value. I have a line chart that i display a single vertical stripLine on for a particular date, but i want that stripLine to go all the way to the top of the chart. The best I was able to do is set the value to the Max value in the dataset, which works alright, but doesn't render as i'd hope.
i'd like the vertical black line to extend to the top. I know I can set the value of that to Max(Fields!Demo.Value) + 10000 and it extends up another 10000, but that usually increases the y-axis max value causing the same spacing issue. Also, sometime the values are much smaller such as 1000 being the max as opposed to 10mil like in the above graph.
The only other thing I could think was just a clunky IIF statement saying
if Max(value) > 1,000,000
add 100,000
else if Max(Value) < 1,000,000 and Max(Value) > 500,000
add 50,000
etc...
I understand it'd be in a long IIf() statement, i can figure that out, just seeing if there was any other way by going through the determined y-axis max.

ssrs row background color based on group total

What i have is a 3 group report, what I want to be able to do is if the sum of textbox145 (which is on group2) is >= make the entire background color DimGrey of group 2. I know how to change the entire row color, however, I am unable to figure out how to do that total of that group based on the data of that groups sum
Thanks!
answered my own question...
=Iif(ReportItems!textbox145.Value >= 10,"DimGrey","Silver")
The Sum function can use a scope argument, so set your background color to:
=IIF(SUM(Fields!FieldNameforTB145.Value, "Group2Name") >= 100, "LightGrey", "Transparent")
The "Group2Name" in there is the magic bit that will give you what you want. This can be set to any parent group name that contains the current data element, but can't be set to a child group. (Which instance would the item use in that case?)