Percentage Calculation In SSRS - reporting-services

when i am calculating like given below in SSRS 2008
=SUM(IIF(Fields!REMARKS.Value = "GOOD",1,0))/((SUM(IIF(Fields!REMARKS.Value = "GOOD",1,0))+ SUM(IIF(Fields!REMARKS.Value = "BAD",1,0))))*100
getting result like 34.9632565235
but i am trying to get result like 34.97%
Please share your expertise.
Thanks

Try:
=FORMAT(
SUM(IIF(Fields!REMARKS.Value = "GOOD",1,0))/
((SUM(IIF(Fields!REMARKS.Value = "GOOD",1,0)) +
SUM(IIF(Fields!REMARKS.Value = "BAD",1,0)))),"P2")
Or you can use a custom string format:
=FORMAT(
SUM(IIF(Fields!REMARKS.Value = "GOOD",1,0)) /
((SUM(IIF(Fields!REMARKS.Value = "GOOD",1,0)) +
SUM(IIF(Fields!REMARKS.Value = "BAD",1,0)))*100)
,"0.00") & "%"
Let me know if this helps.

You can also use the Round function in your expression. With this function =ROUND(..., 1) you will have one number after the decimal point. If you want two numbers after the decimal point then enter 2, and so on. (So you need 2).
Also check the link : Percentage SSRS
Where the example is used :
=Round(((SUM(Fields!FirstCallResolution.Value) / COUNT(Fields!CommunicationId.Value)) * 100),1)

Related

Access 2013 Calculation with If Statement

Maybe someone can help me. What I am trying to do is to create a calculation with an If Condition. I'm doing my current calculations in the field within my DesignerView.
=Summe([Menge/Liter])
=Summe([Menge/Liter]*[Preis/Liter])
Here i need to have that it only calculates the tables that have status = 1
Is there a way how to do this?
Use IIf Function:
=IIF(status = 1, Summe([Menge/Liter]*[Preis/Liter]), Summe([Menge/Liter] ))
Or is it:
=IIF(status = 1, Summe([Menge/Liter]*[Preis/Liter]), "")

Sum values in ssrs with excluding one field

I have a report and need to Sum values from Input_Type (they are Actuals, Adjustment, Estimate, Forecast and Budget, but I need to exclude Budget).
If I use this condition, I get an error.
=SUM(IIF(Fields!INPUT_TYPE.Value = "Actuals" + Fields!INPUT_TYPE.Value = "Adjustment" + Fields!INPUT_TYPE.Value = "Estimate" + Fields!INPUT_TYPE.Value = "Forecast",Fields!VALUE.Value, 0), "GlobalReport")
Could you please help me?
Try the reverse of what you're attempting to write.
=SUM(IIF(Fields!INPUT_TYPE.Value = "Budget", 0, Fields!VALUE.Value), "GlobalReport")

Flash sum total loosing trailing zeros

I have a sum that works out any chosen percentage discount (percentage1.text) of a selected product (status2_txt.text). I've managed to get the value to display just 2 decimal points but it looses its trailing zeros, pulling my hair out!
This is what I currently have:
total_btn3.addEventListener(MouseEvent.CLICK, getTotal3);
function getTotal3(e:MouseEvent):void {
discount1.text = String( Number(status2_txt.text) / Number(100) * Number(percentage1.text));
discount1.text = int((discount1.text)*100)/100;
}
I'd appreciate any help with this!
Thanks
Try function toFixed.
var ret:Number = Number(status2_txt.text) / 100 * Number(percentage1.text);
discount1.text = ret.toFixed(2);

get specific value from parameter

I have a multi-valued parameter TimeMonthOfYear(from cube) that contains January Februrary...December.
I want to set a default value showing current month using MonthName(Month(Today)) (I tried it and it didn't work) when running report...
If I do this [Time].[Month Of Year].&[October] it works! October is selected in dropdown after previous dropdown (Year) was selected.
I don't want to do it the "hard coded" way...I have tried
[Time].[Month Of Year].&[MonthName(Month(Today))] and
="[Time].[Month Of Year].&["&MonthName(Month(Today))&"]" without luck
Any help is very much appreciated!
Yup :) Well it's now working with may be a not so nice solution but will work for now with the help of vb code. in standard value I have ="[Time].[Month Of Year].&[" + Code.SetMonth() + "]" and custom code Function SetMonth() As String Dim x as STRING x =CStr(MonthName(Month(Today))) 'CStr not needed I think If x = "januari" Then x = "January" ElseIf x = "februari" Then x = "February" ... End If Return(x) End Function That is giving me the current month after selecting value in year drop-down :)

Correlate 2 columns in SQL

SELECT ica.CORP_ID, ica.CORP_IDB, ica.ITEM_ID, ica.ITEM_IDB,
ica.EXP_ACCT_NO, ica.SUB_ACCT_NO, ica.PAT_CHRG_NO, ica.PAT_CHRG_PRICE,
ica.TAX_JUR_ID, ica.TAX_JUR_IDB, ITEM_PROFILE.COMDTY_NAME
FROM ITEM_CORP_ACCT ica
,ITEM_PROFILE
WHERE (ica.CORP_ID = 1000)
AND (ica.CORP_IDB = 4051)
AND (ica.ITEM_ID = 1000)
AND (ica.ITEM_IDB = 4051)
AND ica.EXP_ACCT_NO = ITEM_PROFILE.EXP_ACCT_NO
I'm trying basically say since the exp account code is '801500' then the Name should return "Miscellaneous Medic...".
It seems as if what you are showing is not possible. Have you edited the data in the editor??? You are joining using ica.EXP_ACCT_NO = ITEM_PROFILE.EXP_ACCT_NO . Therefore, every entry with EXP_ACCT_NO = 801500, should also have the same COMDTY_NAME.
However, it could be the case that your IDs are not actually numbers and that they are strings with whitespace (801500__ vs 801500 ). But since you are not performing a left-outer join, it would also mean you have an entry in ITEM_PROFILE with the same whitespace.
You also need to properly normalize your table data (unless this is a view) but it still means you have erroneous data.
Try to perform the same query, but using the TRIM function to remove whitespace: https://stackoverflow.com/a/6858168/1688441 .
Example:
SELECT ica.CORP_ID, ica.CORP_IDB, ica.ITEM_ID, ica.ITEM_IDB,
ica.EXP_ACCT_NO, ica.SUB_ACCT_NO, ica.PAT_CHRG_NO, ica.PAT_CHRG_PRICE,
ica.TAX_JUR_ID, ica.TAX_JUR_IDB, ITEM_PROFILE.COMDTY_NAME
FROM ITEM_CORP_ACCT ica
,ITEM_PROFILE
WHERE (ica.CORP_ID = 1000)
AND (ica.CORP_IDB = 4051)
AND (ica.ITEM_ID = 1000)
AND (ica.ITEM_IDB = 4051)
AND trim(ica.EXP_ACCT_NO) = trim(ITEM_PROFILE.EXP_ACCT_NO);