SSIS Visual Studio select only some rows based on length of expression - ssis

I need to find a transformation which will help me select only the red rows from this Excel table in SSIS Visual Studio (2017).
The output table is supposed to have 2 columns, 14 rows.
In the first column, the rows I want to select always have LEN=5 and start with CZ0 (the 2 following numbers differ)... and then I need to add the 5th column with corresponding rows.
I tried Derived Column, Conditional Split, Merge Join etc. in various combinations but nothing seems to work.
Table to select from

Related

SUM of same data in access report based on 2 column

How can I count how many rows have same data in 2 columns on an access report?
This report is always changing based on selections that are made by the user in a combo box and a list box. I want to do the coding in the report. is it possible?
I'm assuming you are looking for rows that have duplicate data across columns 1 and 2. So if in the first row column1 = a and column2 = b, and in another row column1 = a and column2 = b, then we have a duplicate row regardless of other columns. We have found 1 duplicate row.
Access has a find duplicates wizard under the create- query wizard tabs. Playing around with the wizard I got a count of rows with the same data. we subtract 1 to get the number of duplicate rows. Then I had to go to the sql pane of the designer to quickly wrap that query in a sum to get SumDuplicates. The resulting sql which give the total number of duplicate rows is:
SELECT Sum(Duplicates) as SumDuplicates
FROM
(
SELECT Count([column1])-1 AS Duplicates
FROM Table1
GROUP BY Table1.column1, Table1.column2
HAVING (((Count(Table1.column1))>1) AND ((Count(Table1.column2))>1))
);
Adust column and table names to fit your database structure

Using lookup transformation for 2 columns at the same time

I want to use lookup transformation for 2 columns at the same time in SSIS. For example, if there are 3 columns ProductID,CreatedDate,Pname I need to compare 2 columns say ProductID and CreatedDate at the same time so that only if a row has same ProductID but different Created Date it should go in no match output. Currently my transformation is just using productid and if its already exists, it is putting in matched rows even after having a different CreatedDate.
As per above example, both ProductID with 1 should be there in no match output.
How can we implement this in SSIS?
It's very simple. Currently I believe you have only source.ProducID mapped to destination.ProductID in lookup.
All you need to do is map source.CreatedDate to destination.CreatedDate.
You need to do something like this :

SSRS: Need Count of Actual Rows in Report

I have a Text Box in the Footer section of my report with the following expression:
= " Total Loans: " & CountRows("MyDatasetName") & "."
This returns a value that is not the exact number of rows displayed on the report [I manually counted]. There are 30 rows in the report - and the Total Loans reported by my expression is 34.
What I would REALLY like to do is get a count of the rows that are displayed in the report.
If I run the SQL for the Dataset in SSMS - I get 34 rows.
??
Thanks in advance!!
I would assume that your table has a grouping or filter that is limiting your returned rows from 34 to 30. That being said, it doesn't matter why it's limited as you are looking to do a table row count from outside of the table.
I would try adding an additional, hidden column in the table that has an expression in the header cell (not within a row group) like:
=CountRows()
This will return the number of rows in your table, albeit hidden in an invisible column. Now in your footer, create an expression which directly references the previously created textbox in the table like:
=ReportItems!TextBox1.Value
Your other option is to recreate the logical number of rows through an expression. For example, if you have a row grouping on a field called country and you only have 30 distinct counties in your dataset of 34 rows. Then the logical rowcount would be the number of distinct countries:
=CountDistinct(Fields!Country.Value, "Dataset1")

Count calculated Column in SSRS

I have SSRS report where in I am using table with 7 columns (Date, Job ID, Job Name, Status, Output Count, Expected Count, Flag). Out of 7 columns , 4 are directly coming from dataset. Rest three (Job Name, Expected Count, Flag) are calculated columns. I am getting their values from either SSRS custom code or expression. I want to count those rows where Output Count and Expected Count are not matching. Also I have Flag column where I am using Background Color property to check if values are matching or not. So even if I can get count of rows having Red background at Flag column will also server my purpose. Please help me in achieving the same.
You can create some new fields for your dataset to handle calculated values. Then, in your report, you can add some groups and add count or sum values on the table.

Difficult MS Access Query - how to combine them?

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.