How to display grouped data in two table by crystal report - wpf

I hope to display grouped data in two table, like following:
It much like following format:
Group 1:
table 1 table2
1 A 5 E
2 B 6 F
3 C
4 D
It's like the folding of data, once left side table is fully , and then put the data into right side.
In the above case, the data group has six elements, they are {(1,A),(2,B),(3,C),(4,D),(5,E),(6,F)}
Is cystral report support that? And how to meet it, thanks a lot.

After doing some research, I try to use subgroup and put them in both side,
the new problem I meet is the linked parameter what I used is formula, and its content is {PaymentInfo.M_D}+{PaymentInfo.generalOrderGroup}+{PaymentInfo.examName}. However, I don't know why this value is always showing on the subgroup title, like following:
How to hide this infos and delete the upper and bottom empty section, thanks a lot.

Related

How do I display only orders where all items are complete?

I am new to programming so please be kind.
I do not even know where to start with this problem...
I am trying to write a sql view to display only orders that are complete.
I have a table that looks something like this
The result should display orders 1 and 3 since they have all completed items. Order 2 should not be displayed since one of the items is still "F" I only want to show the order once regardless of how many items.
Can anyone please point me in the right direction?
Thanks
software - SQL Server 2005
you can use GROUP BY with HAVING for the conditions that you wanted
SELECT Order_nbr
FROM yourtable
GROUP BY Order_nbr
HAVING MIN (completed) = 'P'
for completed order, the completed column will all be 'P', so MIN(completed) will be 'P'
for non-completed order, the completed column will contain at least a F, so MIN(completed) will gives you F

Select Row values based on values in another row

I have a table that has an auto-incrementing identity "Reference" field and a pair of other fields that determine the sort order. What I need to do is find the 'next' item in the table when sorted based on the pair of fields based on the reference field of an initial item.
So my data looks like this when sorted by SortParent.SortChild:
Reference SortParent SortChild Data
------------------------------------------
9 1 2 Fred
7 1 3 Jim
11 1 4 Sheila
4 2 1 Micro
5 2 2 Archimedes
12 2 3 Electron
So in this example the "Jim" row (Reference=7) comes after "Fred" (Reference=9) even though it's reference is smaller.
So i want to be able to find which row comes after Fred by searching based on Jim's reference
At the moment in code I do a query to find the values for Fred's row:
SELECT SortParent,SortChild From MyTable WHERE Reference=9
Which returns 1,2. Then do a search for the first row that comes after 1,2:
SELECT * FROM MyTable
WHERE ((SortParent=1 and SortChild>2) OR (SortParent>2))
ORDER BY SortParent,SortChild
Which will therefore come back with the row having reference 7 and sort values 1,3
I'm pretty sure this can be done in a single query, but i'm stumped on the best way.
Incidentally, if anyone has any suggestions on alternate way of handling the two part sort columns that would make this easier, please feel free to help!
I believe You are looking at the LEAD or LAG windowed function:
https://msdn.microsoft.com/en-US/library/hh213125.aspx
SELECT
NextReference
FROM
(SELECT
reference
, LEAD(reference, 1,0) OVER (ORDER BY SortParent,SortChild) AS NextReference
, *
FROM
mytable
) newTable
WHERE
reference = 9
I used LEAD, but try it with LAG if you are looking in the other direction for the row
I havn't tested this particular query, so my not be syntactically sound, but let me know if you have any troubles with it and I'll go over it a bit more once I'm back at my desk
EDIT: Used the wrong sql from your question as my base
EDIT2: Put the lead into a subquery to allow us to query on it

SSRS Matrix - one value/row Adjacent?

I have a problem that I have been trying to solve... I Think it is fairly easy but I am new to SSRS. I have made a matrix showing the values of 2 different columns per country on one row. However I want to show only 1 value per row, that means that each country should get 2 rows each.
I Think it has something to do with adjacent but I can't get it right :(
At the moment it looks like this:
France 10 20
But I want it to look like this (don't the dashes...):
France 10
France --- 20
I think this should be possible to do without coding, I just can't find the right property/or Tablix function.
Is there anyone out there who can help me?
Change your data source so that it splits the rows. So for example:
select Country, Value1
From CountryTable
Union All
Select Country, Value2
From CountryTable
You will have to consider your sorting to make sure that your rows are aligned how you need them.
This feels like a weird requirement. But, setting the Row Grouping to Country and then Value should achieve this if I'm understanding your data structure properly.

How can I get SSRS to create subheadings?

The Problem
I'm building an SSRS report which requires regular group headings on certain rows. The data returned from the database query includes a column with a bit flag indicating which rows need to be treated as group subheadings.
Here's a snippet of the source data:
Note the IsGroupHeading column, where the flag is set to 1 on the first row ("0401").
I want to produce output which looks like this Excel mockup:
So every time the report encounters a row where IsGroupHeading equals 1, it generates a bold group heading row followed by a row with column headings.
What's Happening
I've tried creating a row group in SSRS with the expression =Fields!IsGroupHeading.Value = 1 but I get unexpected results: (1) Only the first group heading is treated specially, and (2) the group heading row is repeated underneath the heading. The result looks like this:
Notice that the "0401" row is repeated under the group heading. In addition, only the first group heading ever gets this special treatment. The report simply ignores subsequent group headings and renders them as normal data rows.
The Question
I've spent hours trying to get this right and this is the closest I've been able to get it and my googling on row groups turns up pages mostly about creating subtotals, so I'm throwing this one out to the community hoping some SSRS experts can help me with this.
I'm going to assume that you're doing this in SQL and that all tariff numbers start with the group header tariff number (in this case, 0401).
Let's say your SQL currently looks like this:
SELECT TariffNumber, RowDescription, TariffRate, IsGroupHeading
FROM Tariffs
What we want to do is join this table on itself to give the group TariffNumber and RowDescription columns on each row to enable us to group on it. We also want to exclude the GroupHeader Tariff from the Details rows. So we get something like this:
SELECT TariffGroup.TariffNumber AS GroupNumber, TariffGroup.RowDescription AS GroupDescription,
TariffDetail.TariffNumber, TariffDetail.RowDescription, TariffDetail.TariffRate
FROM Tariffs AS TariffDetail
INNER JOIN Tariffs AS TariffGroup ON TariffGroup.TariffNumber = Left(TariffDetail.TariffNumber, CharIndex(TariffDetail.TariffNumber, '.')-1) AND TariffDetail.IsGroupHeader = 0
Now you just need to group on GroupNumber and you're done.

Using Aggregate Function in SubTable in Visual Studio

I am trying to put together a Subtable on my report in Visual Studio 2008 with SSRS. The problem I am running into is using a function correctly and referencing a report item via my main report. On my report I have an expression that color codes, when a specific value is returned from the main query. In my Subtable, I want to count each instance of a specific value so for example:
Main Report
Supervisor Employee Ranking
Supervisor 1 Employee 1 Meets (Labeled Orange)
Supervisor 1 Employee 2 Outstanding (Labeled Yellow)
Supervisor 2 Employee 3 Meets
Supervisor 2 Employee 4 Meets
Subtable Outstanding Meets
Supervisor 1 1 1
Supervisor 2 0 2
I have tried using the following formulas
=count(Reportitems!Ranking.Value, "Meets", 0)
=count(Reportitems!Ranking.Value, "Orange", 0)
=count(Reportitems!Ranking.Value = "Meets")
=count(Reportitems!Ranking.Value = "Orange")
I have also changed =count to =countrows and =countdistinct
Can someone help? I am open to anything, I just want the report and Subtable to work correctly.
Once you've got a table grouped by Supervisor (and it looks like you do), you'll need to add a couple of columns with two conditional expressions:
Outstanding column:
=Sum(IIf(Fields!Ranking.Value = "Outstanding", 1, 0))
Meets column:
=Sum(IIf(Fields!Ranking.Value = "Meets", 1, 0))
These will count the occurrences of Outstanding and Meets for each Supervisor that is returned.
This assumes that Ranking is just column in your Dataset - you mention colour coding based on this, but we are only interested in the base value, not the colour.
Edit after comment
If Ranking is based off an expression, you can simply add this into the original expressions above, i.e. something like:
=Sum(IIf(<MyExpression> = "Outstanding", 1, 0))
It's a bit of a generic answer since I don't know what your specific example is, but you can certainly nest expressions in other expressions without issue.
For a more elegant solution, you should consider adding a Calculated Field to your dataset - this defines the expression once in the dataset, then you can use it like a normal field within the report itself. This way you would create a Calculated Field called Ranking in your dataset, then you can use expressions like the ones in the original answer referencing this new calculated Ranking field.

Resources