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)
Related
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.
The problem I am having is that my output is not being displayed correctly. For example, what should display 4.99 shows as 499. The amounts in my Stripe database are stored as BIGINT. I've tried using CAST but the decimal is input at the end of my values with trailing 00s and that is not what I want.
What I've tried:
SELECT COALESCE(card_address_country, card_country) AS "Country",
SUM(CAST(amount AS DECIMAL(19,2))) AS "Total Revenue"
FROM charges
WHERE amount_refunded = 0 and paid = true
GROUP BY COALESCE(card_address_country, card_country)
ORDER BY SUM(amount) DESC
$293,839,799 should be $2,938,397.99 and $499 = $4.99.
I've tried dividing the amounts by 100 but it results in a round whole number and the sum is no longer calculated correctly.
SELECT COALESCE(card_address_country, card_country) AS "Country",
SUM(amount/100) AS "Total Revenue"
FROM charges
WHERE amount_refunded = 0 and paid = true
GROUP BY COALESCE(card_address_country, card_country)
ORDER BY SUM(amount) DESC
Is what I am trying to achieve possible? Or am I just using the wrong functions? I was thinking it could be the way the database has been setup as well.
I got a condition
**If charges of any week is zero then that cell has to be highlighted in red
o If charges of any week is 80% to 90% of total average then cell has to be highlighted in
lime
o If charges of any week is less than 79% of total average then it cell has to be highlighted
in light orange**
i tried the following condition:
IIF((SUM(Fields!ChargeAmount.Value)<>0),"Red","White",iif(sum(Fields!ChargeAmount.Value>=80% and sum(Fields!ChargeAmount.Value<=90% ,Fields!ChargeAmount.Value,"")
Can anyone can help me with this .
Supposed that your dataset is named "WeeklyCharges" and the field you use to group by week is named "FirstOfWeek", try the following:
In the properties of the group (FirstOfWeek), define a variable FractionOfTotalAverage using the expression
=Sum(Fields!ChargeAmount.Value)
/ (Sum(Fields!ChargeAmount.Value, "WeeklyCharges")
/ CountDistinct(Fields!FirstOfWeek.Value, "WeeklyCharges"))
For the BackgroundColor property of your weekly charges TextBox, use an expression like this:
=Switch(
Variables!FractionOfTotalAverage.Value < 0.5, "Red",
Variables!FractionOfTotalAverage.Value < 0.8, "Yellow",
Variables!FractionOfTotalAverage.Value < 0.9, "Lime")
Try something like:
IIF((SUM(Fields!ChargeAmount.Value) = 0), "Red",
IIF(SUM(Fields!ChargeAmount.Value) >= 80 and SUM(Fields!ChargeAmount.Value) <= 90, "Lime", "Orange")))
I am new to SSRS and am using 2017 version to make some paginated reports in SSRS with SAP HANA as DS.
I have data which looks like:
SO TYPE LABEL Amount CY Sales
A010 10 Sales 2023
A020 20 Total 100
A030 20 Labour 400
A040 30 Shipping 0
Here CY is the CY and Sales are calculated fields where:
CY = IIF(Fields!SO.Values="A020" and Fields!TYPE.Value=20 , Fields!Amount.Value,0)
Sales = Sum(Fields!CY.Values)
Now when I use the above expression I get result for Sales as #Error and CY as NaN.
The data type for both the expressions is default.
Can anyone help me so that I can get values for CY and Sales.
Your expression should be:
= Sum(Fields!CY.Values)
We have a SSRS Matrix report with the following areas
RowGroup:MonthYear
ColumnGroups:Campaign,Year,Processed
Detail:Sum(Processed)
We have added a single column outside of the ColumnGroup for and expression that will show the increase/decrease of current year processed records over previous year processed records
The data is shaped like this:
lYear, MonthYear, Campaign, Processed
2014, JUL-10, XYZ, 120
2015, JUL-10, XYZ , 60
So the formula is basically CurrentYearProcessed/PreviousYearProcessed which in this example would yield 50%
So how can we specify this when writing the expression?
Just use IIF to filter for the year:
=SUM(IIF(FIELDS!lYear.VALUE = YEAR(GETDATE()), FIELDS!Processed.VALUE, 0) / SUM(IIF(FIELDS!lYear.VALUE = YEAR(GETDATE()) - 1, FIELDS!Processed.VALUE, 0)
This checks your lYear field to see if it's the same as the current year [ YEAR(GETDATE()) ] and sums the Processed field. Then it divides by the previous year's SUM using similar logic.