SSRS 2008 tablix results missing values - ssrs-2008

I have a report that takes an order number as a parameter and shows a tablix with each part number on a row along with the part description, number ordered, number shipped, number remaining to ship, and number on backorder.
SSMS shows the query returns the same number of rows as the tablix shows. However, the tablix has blanks in several places. I have no filters, no visibility settings, and no special conditions. I have zeros set to display as '-'.
The blanks occur below identical values in two columns: Number Shipped and Number Remaining. That is, a value is not shown (only in these two columns) if it is the same as the value above it, like this:
Item Desc #Ordered #Shipped #Remaining #Backorder
1H abc 4 4 - -
2R def 1 - 1 0
5L ghi 6 6 3
7P jkl 6 6 - -
9Q mno 6 -
There should be a - (for zero) for 5L under #Shipped. 9Q should have a 6 under #Shipped and a - under #Remaining, like this:
Item Desc #Ordered #Shipped #Remaining #Backorder
1H abc 4 4 - -
2R def 1 - 1 0
5L ghi 6 - 6 3
7P jkl 6 6 - -
9Q mno 6 6 - -
What is going on?

In the query, try isnull(#Shipped,'-') to catch the rest of the blanks.
If that doesn't work, use the TextBox Expression:
=switch(len(#Shipped)>0,#Shipped,True,"-")
This will replace the blank values with a dash to match the others.

Related

egen tag skipping

I want to tag new occurrences of a new agent_type. I use the following code to do this:
clear
input long patid float(how_many_drugs agent_type eventdate) byte tag4
01 3 4 14962 1
01 3 5 14962 1
01 3 4 14997 0
01 3 9 14997 0
01 3 5 15025 0
01 3 9 15040 1
01 3 4 15040 0
01 3 5 15082 0
end
format %td eventdate
label values agent_type drugstypes1
label def drugstypes1 4 "alpha blocker", modify
label def drugstypes1 5 "ace_inhib", modify
label def drugstypes1 9 "loop", modify
label def drugstypes1 13 "CCB", modify
egen tag4=tag (patid agent_type_new how_many_drugs)
The code works fine, until we reach the first occurrence of "loop" where a tag is NOT generated. Rather, the tag is generated on the second occurrence of "loop".
Why is this happening and how can I make it work to make a tag on first occurrence?
I have made sure that the data were sorted by patid event_date before running the tag code.
As the original author of this egen function tag(), I can comment on its intent.
The intent is not to tag first occurrences as such. The intent is to tag just one of several occurrences which so far as the user is concerned are equivalent.
As it happens, there are only two systematic ways to tag equivalent occurrences, to tag the first or the last. As groups could be as small as one observation, any rule must work on groups that small. For groups of one, choosing the first is the same as choosing the last, but otherwise that is not so. I chose to tag the first in the original code (long since adopted into official Stata), but that is arbitrary.
So why this is happening to you? The function feels totally free to re-sort the data temporarily, as looking at the code will show you:
viewsource _gtag.ado
This is what is biting.
You want to tag the first occurrences of each distinct value of each drug type for each patient. That is one line, as at bottom. I don't understand why how_many_drugs is used in your code.
clear
input long patid float(how_many_drugs agent_type eventdate) byte tag4
01 3 4 14962 1
01 3 5 14962 1
01 3 4 14997 0
01 3 9 14997 0
01 3 5 15025 0
01 3 9 15040 1
01 3 4 15040 0
01 3 5 15082 0
end
format %td eventdate
label values agent_type drugstypes1
label def drugstypes1 4 "alpha blocker", modify
label def drugstypes1 5 "ace_inhib", modify
label def drugstypes1 9 "loop", modify
label def drugstypes1 13 "CCB", modify
bysort patid agent_type (eventdate) : gen first = _n == 1
I've been playing with this for a little while, and in the end abandoned egen tag(). I couldn't understand why it wouldn't pick up the first occurrence of every agent_type so instead I've opted for this:
bys patid agent_type (eventdate): gen n=_n
sort patid eventdate
replace n=0 if n!=1

How to sum across a row in KDB/Q

I have a table rCom which has various columns. I would like to sum across each row..
for example:
Date TypeA TypeB TypeC TypeD
date1 40.5 23.1 45.1 65.2
date2 23.3 32.2 56.1 30.1
How can I write a q query to add a fourth column 'Total' that sums across each row?
why not just:
update Total: TypeA+TypeB+TypeC+TypeD from rCom
?
Sum will work just fine:
q)flip`a`b`c!3 3#til 9
a b c
-----
0 3 6
1 4 7
2 5 8
q)update d:sum(a;b;c) from flip`a`b`c!3 3#til 9
a b c d
--------
0 3 6 9
1 4 7 12
2 5 8 15
Sum has map reduce which will be better for a huge table.
One quick point regarding summing across rows. You should be careful about nulls in 1 column resulting in a null result for the sum. Borrowing #WooiKent Lee's example.
We put a null into the first position of the a column. Notice how our sum now becomes null
q)wn:.[flip`a`b`c!3 3#til 9;(0;`a);first 0#] //with null
q)update d:sum (a;b;c) from wn
a b c d
--------
3 6
1 4 7 12
2 5 8 15
This is a direct effect of the way nulls in q are treated. If you sum across a simple list, the nulls are ignored
q)sum 1 2 3 0N
6
However, a sum across a general list will not display this behavior
q)sum (),/:1 2 3 0N
,0N
So, for your table situation, you might want to fill in with a zero beforehand
q)update d:sum 0^(a;b;c) from wn
a b c d
--------
3 6 9
1 4 7 12
2 5 8 15
Or alternatively, make it s.t. you are actually summing across simple lists rather than general lists.
q)update d:sum each flip (a;b;c) from wn
a b c d
--------
3 6 9
1 4 7 12
2 5 8 15
For a more complete reference on null treatment please see the reference website
This is what worked:
select Answer:{[x;y;z;a] x+y+z+a }'[TypeA;TypeB;TypeC;TypeD] from
([] dt:2014.01.01 2014.01.02 2014.01.03; TypeA:4 5 6; TypeB:1 2 3; TypeC:8 9 10; TypeD:3 4 5)

Pass multiple arguments to a function within select

I'd like to calculate a new column which is a function of several columns using select.
My actual application will involve a grouping in the select so the columns entries which I will pass to the function will contain lists. But this simple example illustrates my question
t:([] a:1 2 3; b:10 20 30; c:5 6 7)
/ Pass one argument, using projection (set first two arguments to 1)
select s:{[x;y;z] x+y+z}[1;1;] each a from t
/ Pass two arguments using each-both (set first arg to 1)
select s:a {[x;y;z] x+y+z}[1;;]'b from t
Now, how can I pass three or more arguments?
Each' will work in general but it's best to use vector operations where possible. Here I use the . operator to apply our function, \t to time both methods. I store their results to r1/r2 to show they are the same:
q)t:([]a:til n;b:til n;c:til n:1200300)
q)\t r1:update d:{x+y+z}'[a;b;c] from t
289
q)\t r2:update d:{x+y+z} . (a;b;c) from t
20
q)r1~r2
1b
q)r2
a b c d
-----------
0 0 0 0
1 1 1 3
2 2 2 6
3 3 3 9
4 4 4 12
5 5 5 15
..
Cheers,
Ryan
The following form works in general
q)t:([]a:til 10;b:til 10;c:til 10)
q)select d:{x+y+z}'[a;b;c] from t
d
--
0
3
6
9
..

Formatting rows of crystal report output

I am a new to crystal report (2008) and need help on my formatting problem.
I have output sample as below in crystal report:
srNo Name ID assigned_number
==================================
1 aaa 111 1
2 bbb 222 2
3 ccc 333 3
4 ddd 444 23
5 fff 445 32
6 ggg 432 1
7 ffr 435 2
8 rty 654 43
9 ttt 434 33
10 trt 343 1
11 rre 346 2
12 gth 543 3
13 fgr 644 54
14 yyy 431 2
15 tut 323 3
16 hyj 777 4
17 juu 322 32
Have a look on last column assigned_number, here I want to highlight the row values (with row color) whenever the last column values are 1, 2, 3 consecutively (not 1, 2 or 2, 3).
So, here srNo 1 to 3 and 10 to 12 should be highlighted with row color as the last column values are 1,2,3(consecutively).
Let me know if it's not clear.
Thanks
You right-click on the field in your assigned_number column and choose Format Field. Then in the Border tab you check the Background box and enter a conditional formula under the "x+2" icon next to Background.
The formula is a little tricky. I have not tested this but it could go something like:
if previous ({assigned_number}) = 1 and
next({assigned_number}) = 3 then crRed
else crWhite
This will color the row with the 2 in it. Unfortunately "next" and "previous" are only limited to one record each way, so for 1 and 3 that won't work.
EDIT:
This formula will work but also highlight 1,2 and 2,3 combos. Even with a formula trying to get the previous 2 records ( the 1,2 when you're at 3) or next 2 (2,3 when you're at 1) doesn't work.
if {assigned_number} in [1, 2, 3] and
previous({assigned_number}) = 1 and
next({assigned_number}) = 3 or
{assigned_number} = 1 and
next({assigned_number}) = 2 or
{assigned_number} = 3 and
previous({assigned_number}) = 2
then crRed
else crWhite
If Right(assigned_number) in [1,2,3]
Then crred
else crwhite.
now you can extend this formula to the any number of values.

Retrieve a particular value from a matrix in SSRS 2008

I have showing value of 5 categories month-wise (4 months) in matrix like as follow:
CategoryA 1 2 3 4
CategoryB 4 5 8 0
CategoryC 2 4 6 7
CategoryD 9 5 4 5
CategoryE 5 4 8 5
Now I have added 1 column (Outside group) in right showing total row-wise. What I am going to ask is that I want to add a row (outside group) to show percentage (Category D / CategoryA * 100) month wise (against all 4 column and "total" Column)
Please suggest .....
You can give a try to the following steps:
Create a calculated column let’s say CategoryDValue in the dataset and use this expression =IIF(Fields!Category.Value=” Category D”,Fields!MonthData.Value,0)
Now in the outside group column cell use this expression =(SUM(Fields! CategoryDValue.Value) / SUM(Fields!MonthData.Value)) * 100