I am working on a SSRS report which needs to show a blank row after every group. The group by field is "category". The values it takes are "first quarter 2010", second quarter 2010", "first quarter 2011", "second quarter 2011". I want the data in the column as follows:
Category
First Quarter 2010
Second Quarter 2010
First Quarter 2011
The report gets populated by a sql query. The problem I am having is inserting the blank row after each group.
I have tried to insert a row below inside the group and play around with its visibility property. But have failed. I have also tried to include
UNION NULL, NULL, NULL in my sql query to insert a blank row. BUt since my dataset is huge I am afraid formating in sql will slow the process down .
Please suggest and also let me know if You need more detais. Thanks in advance.
Using the union in your SQL query is the right direction, but you need to use "union all" instead of "union" to keep the database from filtering the result set for unique. Using union all will just add another row and the performance impact should be inconsequential.
Related
i want row headers to appear in every after of each month in my SSRS report like in the picture below
reference
Create a calculated field that returns the month of the date. The can be done either in the dataset SQL or as a calculated field in the dataset.
Add a parent row group that is grouped on this new calculated field.
Right-click on the textbox where the date field currently is. Select "Insert Row" then "Outside Group - Below".
Delete the extra first column that was added when you created the row group.
The design should look something like this:
Notice that the Date field is inside the child row group. This means you will get rows for each date. The parent row group is grouped on the month calculated field. So it will repeat once per month.
SSRS (both 2008 and 2016 are doing the same thing) is not showing values. I have a column "Status" with three different possible values. Every row is populated in the result set of my query in SSMS. But in the SSRS tablix, more than half of the rows are blank.
If you have a 'group by' in your sql query, try removing it or change the order. Make sure it is in the right order of grouping. For example in my query, I had the following grouping
Group by Year, Measures, ProgramID, Program
This was giving me the same issue because the right order for the data was
Group by Year, ProgramID, Program, Measures
I have edited my question and replace the previous explanation with new one.
I think I could't explain my problem clearly before. here is my scenario:
Col1 |Col2 |Col3 |Col4 |Col5 | Col6
------|------|------|-------|------| 3333.00 (Table 1)
------|------|------| 15.00| 0.00| 3348.00 (Table 2)
------|------|------| 0.00|550.00| 2798.00 (Table 2)
Sub ToTal:-----| 15.00|550.00| 2798.00 (Table 3)
In this report value (3,333.00) of Table 1 is Opening Balance. For Table2 and Table3, col4 is Deposit and Col5 is Withdraw. Last column of Table2 and Table3 are closing balance. So, the rule is, closing balance of first row of Table2 should be calculated as (ClosingBalance = OpeningBalance + Deposit - Withdrawal). and Closing Balance of 1st row should be opening Balance for second row. Table 3 has nothing to do with them.
Now problem is that 3333.00 is coming from query so we can easily calculate 3348.00 but i dont know how to calculate 2798.00 as it required value of above cell which is 3348.00. similarly if Table 2 generate 10 rows than 1st value of last column should be calculated from 3333.00 and remaining rows will calculate their values from above cell i.e 2798.00 depends on 3348.00 and if there is next row than it will depend on 2798.00. so i have done this:
IIf(RowNumber(DatasetName) = 1, value of Table1(3333.00) + and remaining values to calculate 3348.00, Previous(ReportItems!MyTextBoxName.Value) + other values)
Now it gives me error:
The Value expression for the textrun 'Amount8.Paragraphs[0].TextRuns[0]' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers.
I searched over different forums and found out that I can't use ReportItems in this scenario. So, what should I do?
I know my scenario is complicated and its more complicated to explain it but I tried my best. Please tell me any solution you have.
Try Previous(Copy the expression used in your MyTextboxName)
You can use Lag function in your SQL Statement to get to previous value.
SELECT Field1, Lag(Field1,1,NULL) OVER(PARTITION BY .... ORDER BY ....)
FROM Table1.....
Here are couple of articles to help you understand Lag in Detail
Intro to Lead and Lag By Pinal Dave
Lead and Lag function article in DatabaseJournal
I have a list of records that have a date/time field/column; I want a query to get just the distinct days (removing the time, like 1/1/14, 1/2/14, etc) & sorted correctly. Its going into a form's combo box row source so a user can filter/narrow-down the info on the screen per day
Here is my original query:
SELECT TOP 1 "*** ALL ***" AS ord_tdate FROM qryOrderEntriesNotBilled
UNION SELECT DISTINCT FORMAT(ord_tdate, "mm/dd/yy") FROM qryOrderEntriesNotBilled
ORDER BY 1;
Here is a simplified view for the sake of the question at hand:
SELECT DISTINCT FORMAT(ord_tdate, "mm/dd/yy") FROM qryOrderEntriesNotBilled
ORDER BY 1;
Both of the above work, but the order is wrong, its obviously sorting by number (1st one) rather than overall value as seen here:
Things I have tried unsuccessfully:
DATEVALUE(ord_tdate) solved the simplified view, but with original query (union) it doesn't work correctly as seen below
CDate(Datevalue(ord_tdate)) & CDate(FORMAT(ord_tdate, "mm/dd/yy")) had same results as above
Include a second field expression, DateValue(ord_tdate), in the row source query. Sort by that field. In the combo properties, select 2 as the column count and set the column width for that second column to zero.
This query returns what I think you want in Access 2007 with qryOrderEntriesNotBilled as an actual table instead of a query.
SELECT DISTINCT
FORMAT(ord_tdate, "mm/dd/yy") AS date_as_text,
DateValue(ord_tdate) AS date_as_date
FROM qryOrderEntriesNotBilled
UNION ALL
SELECT TOP 1
"*** ALL ***",
Null
FROM qryOrderEntriesNotBilled
ORDER BY 2;
My personal preference is to use a custom single-row Dual table for the "fabricated" query row. If you would like to try that approach you can find a procedure to create your own here. But a dedicated table is absolutely not a requirement for this. It's purely a matter of developer preference.
I am trying to build an access report based on data from multiple different tables within the database.
I have 3 columns which perform calculations, and I am wondering how to put this query together. All 3 columns deal with dates, but calculate them differently.
The first column retrieves the most recent date of action for a userid if the type of action is "B":
select pid, Max(date) as most_recent
from actions
where ref = 'B'
group by pid;
The second column performs a calculation based on 2 fields, one is a date and one is a number in months. I am unsure how to add these two fields so that the number is added to the date as a number of months.
what i have so far is:
select nummonths,Max(lastvisit) from users
the third column I need to select the first date thats in the future for each user (next appointment date), there will be dates before and after this date so its a little difficult:
select uid,date from visits
The code for the last 2 queries needs to be slightly modified, and I was wondering what the best approach would be to join these all together? A type of join?
If you need to build a report with data from the 3 queries, you will need related data to join them. In that case, please send the structure of the tables.
If you need to show 3 lists in one report, you can use subreports: create a new empty report. In design mode, you can add 3 subreports from the toolbox bar. To each of the subreport assign the record source property to the corresponding sql.
regards
I am unsure how to add these two fields so that the number is added to the date as a number of months.
Use the DateAdd() function:
SELECT DateAdd("m", 2, LastVisit) FROM ...
Results in a date two months from the LastVisit date.