Rdlc reporting issue expresssion in report not running - visual-studio-2010

I created 4 reports all of them worked i have an expression in all to count rows:
=IIF(Fields!Logged30Days.Value = "yes", Count(Fields!Logged30Days.Value),0)
But today i see on all this is returning 0 when there are rows in the report it suddenly stops working how to fix this and why is it happening?
UPDATE
Now i see the expression are not working on any report, even on the earlier backup versions where they worked!
And if i do this it works but for all the rows just to show expression works ! but its not working as it did before above.How do i change this below to get desired result.
=IIF(Fields!Logged30Days.Value = "yes", count(Fields!Logged30Days.Value),count(Fields!Logged30Days.Value))

OK, it seems like all you need is the following expression:
=Sum(IIf(Fields!Logged30Days.Value = "yes", 1, 0)
All this is doing is counting the rows with a yes value for Logged30Days; it the value is not yes it's just ignored for the count.
In your case,
=IIF(Fields!Logged30Days.Value = "yes", Count(Fields!Logged30Days.Value),0)
is the same as:
=IIF(First(Fields!Logged30Days.Value) = "yes", Count(Fields!Logged30Days.Value),0)
i.e. when there is more than one row in the Scope but no aggregate specified it will just take the first row. So the expression was determined by the first row's value only. Also, when the first value was yes the Count would count all rows, even those where the value was not yes, which was also not quite what you were after either, I think.

Related

SSRS Matrix percentage calculation for single row

I have a matrix to show pivot values of IN Network and OUT of Network invoices. I need to find 'IN Network total'/'Grand total' as a percentage. my expression is looking like this.
=switch(Fields!Network_Type.Value="IN Network", Fields!ClientInvoices.Value/sum(Fields!ClientInvoices.Value))
But I got only values for 2 columns.Could anyone please guide me how to find the percentage at the required row.
The switch function is usually used for evaluating multiple conditions instead of just one, but would still work in this setting. I think the issue is that you're applying the switch function row by row, and it will only return a value if the condition is true - so if the condition evaluates false for the last row in the set, it gives back nothing. You may wish to structure it so that it sums all of the instances in which the condition evaluates to true, then divide by the overall sum:
=sum(switch(Fields!Network_Type.Value="IN Network", Fields!ClientInvoices.Value))/sum(Fields!ClientInvoices.Value)

Pulling data from Crystal Reports

My data is stored in Oracle and the only way I can run a report with it is using Crystal Reports. I have a set of data that looks like this ,,,,,,,,,,1, or ,1,,,,,,, or ,1,,,,,1,,,,1,. There are more variations.
Each one means a value is true for a record. There are about 54 'ticks/commas' What I want is all records with the one at the X spot. So for one report I may want all records in the 10th spot that have a 1. There may be other times where I want the records where the 1 is after spot 36. I agree it will pull other records but the main once I want is the X spot.
How do I get this? I tried a Like command but that does not narrow the data down far enough. I am familiar with SQL but not Crystal.
Any help would be great. TIA
In Crystal, you might try setting up a Parameter Field to hold a numeric value (1 to 54) then use that in a formula as the Record Selection. You'll be prompted to enter the parameter when you run the report.
In record selection i was initially going suggest the following which would bring back all records with 1 in the 12 spot. But this makes it hard to bring back a range.
split({yourfield},",")[12] = 1
This will bring back the same
instr({#test},"1") = 12
Then for your suggestion above you could use the following to bring back any record if it has a one in any spot after 36
instr({#test},"1") >= 37
As long as there is only one 1 in the field you can use this for other ranges as well.
Actually I don't want to disturb both answerts by Clayton Morris and CoSpringsGuy hence posting my answer.
You need to combine both the solutions to get the desired result.
Create a number parameter and provide either 1 to 57 numbers or keep just a filed to enter desired number.
Now in record selection use the formula given by CoSpringsGuy
if instr({databasefield.column},"1") = {?Inputnumber} --parameter field
then {databasefield.column}

Show All if parameter is null Crystal Reports

Hi everyone I use Crystal Reports with Visual Studio 2010 and have the following issue that I can't seem to solve. I have a parameter called name, and I make it so a user chooses from a drop down list of employee names. It is an optional parameter so the user can select nothing in which case I would like the report to show ALL the employees except for the rows that have field Employee name empty. Now I think I got the second part of it down, because I put a formula in the detail section that seems to hide all the empty employees. The problem is that if I leave the parameter unselected the report ONLY shows rows with field Employee name empty. I created a formula like so:
if not (hasvalue(({?Zaduzioc}))) then True
else if
hasvalue({?Zaduzioc}) then
{Inventar_Model_ReportClass.ImeZaduzioca} in {?Zaduzioc} and
{Inventar_Model_ReportClass.Status} = "Aktivno"
Now this exact same formula works for me if I use it with a different report and parameter but that parameter has no empty values so I'm guessing it equates to something like if there are empty values show only those rows if not show everything.
The problem is I can't figure out how to tell it to show everything.
Any help would be greatly appreciated.
I managed to make it work, the problem was in the edit for the parameter I didn't set optional to true, overlooked it and as soon as I did that it all worked. So to recap for anyone with this problem: Make your parameter set optional to true, and put this in the formula for record selection:
if not (hasvalue(({?Parameter}))) then True
else if
hasvalue({?Parameter}) then
{table.column} in {?Parameter}
That should be that.
If you are selecting from a dropdown, you can add an item, Value = ALL, Description = ALL. Set your default to this value. Then in the Selection Expert, add this to your selection query:
....
AND
(IF {?Parameter} = 'ALL' THEN
{databasefield} = {databasefield}
ELSE
{databasefield} = {?Parameter})

Controlling Sorting in SSRS Based Upon a Database Text Field

I've been trying to find a way to even search for this without much luck.
Basically, I've got a text field in a table. All I'm trying to do is check if that text field contains a particular string, in this case, if this field contains either "OLD", "OBSOLETE", or "FOM" and then move it to the very bottom of the list, leaving everything else sorted normally. Is this possible? I'm trying to do this without hitting the SQL Statement itself too much if at all.
You can do this by using a switch statement in the expression/function related to the sort. Logically a switch() is very similar to a case statement.
Under 'sorting options' add a new sort line item (or modify the existing item) by clicking the expression button to the right (Fx)
Then Modify the sort expression similar to this:
=Switch(Fields!YourField.Value="Old","xxx",
Fields!YourField.Value="Obsolete","yyy",
Fields!YourField.Value="Fom","zzz",
1=1,Fields!YourField.Value)
This creates a switch statement that replaces the value to be sorted of the items you mentioned to xxx,yyy, & zzz effectively moving their sort value to the end of the list. Their displayed value will remain the same.
Switch stops evaluating when it finds the first true; so the final 1=1 is basically the otherwise clause that says sort by whatever the actual value of your field is when not old, obsolete, or fom.

Counting gone horribly wrong

I'm trying to create a rdlc report in Visual Studio 2008 and I'm having a bit of trouble with the totals at the end.
I have a string field called "Reward" that displays either 1, 2, 3 or B. At the end of the report, I need to count up how many total records, how many "B"s and how many are not "B"s. So my inclination is to have three fields at the bottom as such:
Total =COUNT(IIF(Fields!Reward.Value > "a",1,0))
Bs =COUNT(IIF(Fields!Reward.Value = "B",1,0))
Non-Bs =COUNT(IIF(Fields!Reward.Value <> "B",1,0))
But all three end up equaling the same (the total record count). I thought that seemed weird so I tried data that doesn't appear in that column at all such as
=COUNT(IIF(Fields!Reward.Value = "4",1,0))
and I still get the same number. Any ideas what I'm doing wrong?
Perhaps you want SUM instead of COUNT?
If you're returning value 0 or 1 from your IIF, you're actually just counting how many values are being returned, no matter the numeric value within.
Change the Bs and Non-Bs to SUM, and you'll get the results you're looking for.

Resources