I have two Datasets,
These two Datasets have different amount of rows.
I have two Tablix. Each Tablix point to these two different Datasets
In one column I want to compare both DataSets row by row.
So the Idea of what I want is this:
These are my two Tablix with my Datasets, as you can see Student number 10,15 and 23 does not exist on Dataset2.
When this happens I want to write a 0.
If I use a Lookup expression it will give me an error as it compares the rows that exists for each Datasets:
=IIF(Fields!Student.Value <> Lookup(Fields!Student.Value,Fields!Student.Value,Fields!Student.Value,"Dataset1"),"0","1")
That expression will give me an error.
The idea (I think) is to persist the Student 21 and compare for each student on Dataset 1 and when they are equal write 1 and 0 while they are not equal but for each row.
I cant touch the Datasets, I mean the queries.
Let me know if you need more info.
EDIT: To give you more info, what I want to do is to replicate what my code behind in my web application does in the Data Layer:
ReportsDataSet.MyDatasetRow drSchool = (ReportsDataSet.MyDatasetRow)repDset.MyDataset.Rows[0];
string Student = drSchool.Student;
bool firstone = true;
bool hayApproved = false;
bool hayNotApproved = false;
bool hayNeedMoreStudy = false;
bool hayFail = false;
bool hayG5 = false;
bool hayNC = false;
if (repDset.MyDataset.Rows.Count > 0)
{
int Count = repDset.MyDataset.Rows.Count;
for (int i = 0; i < Count; i++)
{
ReportsDataSet.MyDatasetRow dr = (ReportsDataSet.MyDatasetRow)repDset.MyDataset.Rows[i];
if (dr.tipo.Trim() == "TOTAL" && firstone)
{
Student = dr.Student;
firstone = false;
switch (dr.categoria.Trim())
{
case "Approved":
hayApproved = true;
break;
case "NotApproved":
hayNotApproved = true;
break;
case "NeedMoreStudy":
hayNeedMoreStudy = true;
break;
case "Fail":
hayFail = true;
break;
case "G5":
hayG5 = true;
break;
case "N/C":
hayNC = true;
break;
}
}
else
{
if (dr.tipo.Trim() == "TOTAL" && dr.Student == Student)
{
switch (dr.categoria.Trim())
{
case "Approved":
hayApproved = true;
break;
case "NotApproved":
hayNotApproved = true;
break;
case "NeedMoreStudy":
hayNeedMoreStudy = true;
break;
case "Fail":
hayFail = true;
break;
case "G5":
hayG5 = true;
break;
case "N/C":
hayNC = true;
break;
}
}
}
if (dr.Student != Student || i == (Count-1) )
{
if (!hayApproved)
{
repDset.MyDataset.AddMyDatasetRow(Student, "Approved", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
if (!hayNotApproved)
{
repDset.MyDataset.AddMyDatasetRow(Student, "NotApproved", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
if (!hayNeedMoreStudy)
{
repDset.MyDataset.AddMyDatasetRow(Student, "NeedMoreStudy", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
if (!hayFail)
{
repDset.MyDataset.AddMyDatasetRow(Student, "Fail", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
if (!hayG5)
{
repDset.MyDataset.AddMyDatasetRow(Student, "G5", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
if (!hayNC)
{
repDset.MyDataset.AddMyDatasetRow(Student, "N/C", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
if (!hayApproved && !hayNotApproved && !hayNeedMoreStudy && !hayFail && !hayG5 && !hayNC)
{
repDset.MyDataset.AddMyDatasetRow(Student, "TOTAL", "TOTAL", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
Alreadyfilled++;
}
repDset.MyDataset.AcceptChanges();
hayApproved = false;
hayNotApproved = false;
hayNeedMoreStudy = false;
hayFail = false;
hayG5 = false;
hayNC = false;
firstone = true;
if (i != (Count - 1))
{
Student = dr.Student;
i--;
}
}
}
}
EDIT 2:
As you can see in the last image, Student 11, 16 etc does not exist on Dataset 2 in those cases I have to put "0". But what Im doing with Lookup is comparing 21 with 11,21 with 11 again,22 with 11 and so on. And thats not the point, the point is to put 0 for each time the Student that exists in Dataset1 does not in Dataset2.
It should be something like, I save the value of the Student in Dataset 2 and compare for each Student on Dataset1, when they are not equal, put 0 when they are equal, put 1.
A Function maybe? save all the students of Dataset1 on a list and Students of Dataset2 on another lists and compare them on a foreach inside a custom code?