calculate the percentage base on condition in SSRS - reporting-services

I want to calculate the the percentage of success program
So this calculation will base on 2 fields
One is "ID" and another is "Status"
The idea is to calculate the "Finished" and "Running" over total count "ID"
the syntax will be =(count(id) if status = "Finished" + count(id) if status = "Running" ) / count(total id) /100
but i dont know how to write this in SSRS expression. any help?
So the result that im excepting is a percentage based on STATE The STATE has 3 result -- Finished Running and Failed I want to calculate the percentage of Finished + Running / total number

I'm not sure why you are dividing by 100 but this will give you the decimal version o of the percentage value (e.g. 0.4 = 40%). You can then format the textbox using, for example P2 (percentage with 2 decimal places) as the format property.
=
SUM(IIF(Fields!Status.Value = "Finished" OR Fields!Status.Value = "Running", 1, 0))
/ CountRows()
This assumes that you want the count of all rows with a Status of "Finished" or "Running" as a percentage of the total rows in the dataset.

Related

Access query is asking for parameters for calculated field, how can I stop this?

I have a query set to calculate units processed per hour by user. The query returns the correct numbers when I run it, however every time that I run it , it will ask for parameters for two fields and I just click "ok".
When I link the query to a report, it will not display anything, but it does when I just open the query. What is going on ?
My query is set up as such .
Column1 - Group By USERID
Column2 - Sum of NBR OF UNITS: NBR OF UNITS
Column3 - Sum of DURATION: DURATION
Column4 - Expr1: [Sum Of NBR OF UNITS] / [Sum Of DURATION]
The Parameters asked for are
Sum Of NBR OF UNITS
Sum Of DURATION
Column4 (if required) should be changed to:
Expr1: [NBR OF UNITS]/[DURATION]
Or, if a summation is required:
Expr1: Sum([NBR OF UNITS]/[DURATION])
You are prompted for the parameters because the aliases Sum Of NBR OF UNITS & Sum Of DURATION are not defined when the division expression is evaluated.

SSRS Add Row Percentage to Tablix

I am trying to add some kind of calculated item (Excel equivalent) into a tablix I have created from a dataset.
e.g.
Type Today Month Annual
Sales 1,000 15,000 35,000
GP 200 1,500 5,000
I want to add a row below that will calculate the margin % and also be dynamic so when the figures change, so will the Margin %
e.g.
Type Today Month Annual
Sales 1,000 15,000 35,000
GP 200 1,500 5,000
Margin % 20% 10% 14.3%
If this is in the footer, then you can conditionally sum on the field Type, for example for the Today column:
=SUM(IIF(Fields!Type.Value = "GP", Fields!Today.Value, Nothing)) / SUM(IIF(Fields!Type.Value = "Sales", Fields!Today.Value, Nothing))
Of course, if Sales can be zero then you will get divide-by-zero errors so you need to make the expression a bit more complicated to bypass the error-generating divide-by-zero calculation of the IIF function parameters:
=IIF(SUM(IIF(Fields!Type.Value = "Sales", Fields!Today.Value, 0.0)) <> 0.0,
SUM(IIF(Fields!Type.Value = "GP", Fields!Today.Value, Nothing)) / IIF(SUM(IIF(Fields!Type.Value = "Sales", Fields!Today.Value, 0.0)) = 0.0, 1.0, SUM(IIF(Fields!Type.Value = "Sales", Fields!Today.Value, Nothing))),
Nothing)

SSRS report builder 2014 CDbl precision

I have some column in my report, calculated the Sum using this exepression :
=SUM(IIF(Fields!Type.Value = 0, CDbl(Fields!Amount.Value), CDbl(0.0)))
it works but gives me the sum with no precision.
is there a way I can view the Sum with precision?
UPDATE
the Fields!Amount.Value is alway decimal(18, 3)
If The calculation was like sum = 10 + 10 the result becomes 20
if sum = 10 + 2.125 the result becomes 12.125
I want the result to be converted to (18, 3).
so I expect the result in the first example to be 20.000
Your report is correctly returning the values to the necessary precision, it is just only showing the significant figures because you have not told it what number formatting you require and is making a best guess.
If you change your expression to the below, you should get your desired output:
=FORMAT(SUM(IIF(Fields!Type.Value = 0, CDbl(Fields!Amount.Value), CDbl(0.0))),"0.000")

How do I group following dates in MySQL

I have a timeseries of discharge data. I want to select certain peak events.
What I did was calculate a treshold, and made a table with the exceeding periods:
%create the treshold value
select min(dummie.value) from (select top 5 percent value from timevalues where id =
(select id from source where type = 'observation') as dummie) as treshold
%view every time where the value is higher then treshold
select name, time, value from timevalue, catchment
where timevalue.sourceID = source.id
and where source.id = catchment.sourceID
and where value >= treshold.value
as exceed_table
Now I want all the periods that the values are above this treshold, and then count how many they are. is there a way to remove all the data where it's one timestep further then the one before?
Thanks!
I solved it by copying the exceed_table, adding one timestep to it and then substracting the exceed_table and the copied one.

SSRS Position calculate Expression

I am trying to show the Postions of student on the basis of aggregate (aggregate )
The Aggregate expressions calculating on basis of (FINAL + MOCK + Asst)/3 which m doing on run time expression calculate...
Now i am unable to display the position positions Column highest the aggregate highest positions(1 OR 2 OR 3 ) positions
Is there any expression i can write to show positions column.
please help me m stuck
There's not a function that you can use - you'd just need to use some IIFs:
=IIF(FIELDS!Final.VALUE >= FIELDS!Mock.VALUE AND FIELDS!Final.VALUE >= FIELDS!Asst.VALUE, 1,
IIF(FIELDS!Mock.VALUE >= FIELDS!Final.VALUE AND FIELDS!Mock.VALUE >= FIELDS!Asst.VALUE, 2, 3))