0
votes

Good day, I have searched everywhere and seems like the lookup function might be the solution but I need some advise. I have a report with more than one dataset linked to it. Tablix 1 returns a count based on a name field and groups(counts) it per date on specified date range. Tablix 2 returns details on tablix 1's count with more fields including the date per row.

I need to add a "click_link" on Tablix 1 so that when you click on any of the counted values it must return the detailed data from tablix 2 but only if the date matches.

Image of Tablix 1:

Tablix 1


Image of Tablix 2:

Tablix 2

Image of Tablix 1's data returned without where clause

This is the query for dataset 1(Tablix 1)

    DECLARE @Actual  int;
DECLARE @Date  varchar;

SELECT Actual.Actual,Actual.DateActual,Original.Original,Original.DateOriginal FROM 
(
    Select count (payhist.AC_CODEID) as Actual,PAYHIST.PH_DATE as DateActual from PAYHIST
    join Paymonth on PAYHIST.PH_DATE >= Paymonth.ph_datesd  and  PAYHIST.PH_DATE <= Paymonth.ph_dateed
    Join EMPLOYEE E on PAYHIST.MST_SQ = e.MST_SQ
    Join Worklocation wl on e.wl_codeid = wl.wl_codeid
    Join Paymonth pm    on PAYHIST.PH_DATE >= pm.ph_datesd and PAYHIST.ph_date <= pm.ph_dateed 

    where Paymonth.CurrentPD = 1
    and PH_EXCEPTION = 1
    and e.EMP_DISCHARGE is null
    and e.EMP_CONTRACTOR = 0
    and wl.WL_CODEID = 1

    GROUP BY PAYHIST.PH_DATE 
) AS Actual 

FULL JOIN 

(
    Select count (PAYHISTTEMP.MST_SQ) as Original,PAYHISTTEMP.PH_DATE as DateOriginal  from PAYHISTTEMP
    join Paymonth on PAYHISTTEMP.PH_DATE >= Paymonth.ph_datesd  and  PAYHISTTEMP.PH_DATE <= Paymonth.ph_dateed 
    Join EMPLOYEE E on PAYHISTTEMP.MST_SQ = e.MST_SQ
    Join Worklocation wl on e.wl_codeid = wl.wl_codeid
    Join Paymonth pm    on PAYHISTTEMP.PH_DATE >= pm.ph_datesd and PAYHISTTEMP.ph_date <= pm.ph_dateed 
    where Paymonth.CurrentPD = 1
    and PH_EXCEPTION = 1
    and e.EMP_DISCHARGE is null
    and e.EMP_CONTRACTOR = 0
    and wl.WL_CODEID = 1

     group by PAYHISTTEMP.PH_DATE
) AS Original ON Original.DateOriginal = Actual.DateActual

where (@Actual = '-1' or @Actual = Actual.Actual)
and (@date = '-1' or @date = Original.DateOriginal)

 order by DateOriginal Asc

And this is the query for dataset 2

Select  e.EMP_EMPNO,e.emp_Firstname,e.emp_surname,d.DPT_NAME,a.AC_NAME,ph.PH_DATE as PAYHIST_DATE,d.DPT_RESPEMP,
ph.PH_FIRSTCLOCK,ph.PH_LASTCLOCK,WL_NAME 
into EXCEPREPORT
from PAYHIST PH 
Join EMPLOYEE E on ph.MST_SQ = e.MST_SQ
Join DEPARTMENT D on ph.DPT_CODEID = d.DPT_CODEID 
join ATTEND A on ph.AC_CODEID = a.AC_CODEID
Join Worklocation wl on e.wl_codeid = wl.wl_codeid
Join Paymonth pm    on ph.PH_DATE >= pm.ph_datesd and ph.ph_date <= pm.ph_dateed

where pm.CurrentPD = 1
and PH_EXCEPTION = 1
and e.EMP_DISCHARGE is null
and e.EMP_CONTRACTOR = 0
and e.wl_codeid = 1

select pht.EMP_EMPNO,pht.EMP_FIRSTNAME,pht.EMP_SURNAME, DPT_NAME,e.emp_firstname as RESP_FIRSTNAME,e.emp_surname as RESP_SURNAME,
AC_NAME,PAYHIST_DATE,PH_FIRSTCLOCK,PH_LASTCLOCK,WL_NAME as WORKLOCATION
  from EXCEPREPORT pht
  join employee e on pht.dpt_respemp = e.mst_sq

drop table EXCEPREPORT

@Harry, I am completely confused now...Should the parameters be added on the summary or details tablix? I am only interested in the details of the outstanding transactions. Which I get from the summary tablix's data set. The query returns a count of one of the columns namely(AC_CODE) as well as date and the same query (using full join) to run two select queries each to different tables does a count on a similar column and date(Results as link of picture above). The details are then returned with Tablix 2's data set which is a different query and there are no identical column names except the date which is the same on both queries with different column names. Ultimately I want to send this report out as a Excel attachment and if you click on one of the dates on summary in outstanding row it must sort of bookmark to the detail sheet but only show details for relevant date above outstanding number selected. I hope this makes sense?

Please let me know if you require any additional info?

2
So if the Outstanding value was >0 you want to be able to click on it and show the details.. is that correct? What you could do is have another tablix on the main report that loads the corresponding data.. hide it initially, and on clicking the reportitem, if value is >0.. show the other tablix with the appropriate details..Harry
Hi Harry, yes this is exactly what I need. I have created the second tablix with details but not sure how to link tablix 1's data with tablix 2 and apply filter?Gerhard Steyn

2 Answers

0
votes

Lets assuming you have two tablix on your report.

TablixA which has the summary

TablixB that has the detail

You would have two datasets (dataset1 for the summary and dataset2 for the detail).

You already have Dataset1 and displaying TablixA without any issues.

What you need to for the details one do is have a couple of extra parameters on your Dataset2. Lets call them @status and @date

Your code / stored procedure for Dataset2 will have at the end of your where clause the following

where....
and (@status = '-1' or @status = yourtable.column_that_holds_status)
and (@date = '1990-01-01' or @date = yourtable.column_that_holds_the_date)

This will create two parameters on your report (Status and date)

Set the default value for these parameters status '-1' and date = '1990-01-01'

Set the initial visibility of TablixB to hidden.

Now on TablixA select the text box that you want to click on (lets call this textbox_click). Right click on textbox_click then go text box properties ->Action. Select "Go to Report". Under Specify a report - select the report that you are currently designing and click Add. Now click on the parameter under Name one at a time until you have all the parameters required for this report covered. Say if you had 1 parameter for TablixA called param1.. so under Name you will have param1 and the value should be set to what the initial parameter was (click on the fx next to value and select that parameter). Now for the Name Status - select the field (column_that_holds_status) for the field list of dataset1 and date as the field from Dataset1 (column_that_holds_the_date)

Click ok.. assuming everything has been set correctly .. you can now run the report.. and when you move your cursor over the value, it should turn into a finger telling you can click.. click and then it should reload the report.. but now show the second tablix with the correct data in it.

To stop from user clicking on 0 values.. once you have everything working.. go to the "specify a report" then click the fx and use the following

=iif(reportitem!textbox_click.value>0,"Name or your currentreport",0)

It's heaps easier to show then explain.. but hope this gets you started on where you need to get to.

0
votes

Lets Assume your report is called report1 Lets also assume you have the following result set from dataset1 (ignoring the actual set that is returned)

Bulyanhulu      Date            value
Original        22 Jan 2018     1
Original        25 Jan 2018     4
Original        26 Jan 2018     6
Original        27 Jan 2018     1
Original        02 Feb 2018     21
Outstanding     22 Jan 2018     0
Outstanding     25 Jan 2018     0
Outstanding     27 Jan 2018     0
Outstanding     02 Feb 2018     6
Cleared         22 Jan 2018     1
Cleared         25 Jan 2018     4
Cleared         27 Jan 2018     6
Cleared         02 Feb 2018     15

The above would be easy to lay out as a matrix (Tablix1)

Now for you second dataset for the details (dataset2)

You need to make sure it is returning the Bulyanhulu column as well as the date column along with other columns that you want for the details tablix( Tablix2)

So for the second data set .. you should have something like this

Select 
Bulyanhulu
,Date
,whatever other colums you want
from your_table
where
(@Bulyanhulu = '-1' or @Bulyanhulu = Bulyanhulu)
and
(@date='-1' or @date = Date)

once you have done this to your dataset2, you will see two new parameters : @Bulyanhulu and @date.

Make them Hidden

Set the default value to -1 for both the parameters

You have two tablix, Tablix1 and Tablix2

Say if we pick on Bulyanhulu-Outstanding for date '02 Feb 2018' (which has a value of 6) on Tablix1

Right click on the text box (lets call it textbox1) and select properties -> Action

Select Go to report

Specify report1 under "Specify a report"

Click Add to add both your parameters

on the first line for paramenter Bulyanhulu select [Bulyanhulu] for the value

on the Second line for paramenter Date select [Date] for the value

once you have done this.. click on the Fx next to Specify a report and type in the following

=iif(reportitems!textbox1.value>0,"Report1",0)

This ensures that you cannot click on any values that is 0 in tablix 1

Set your Hidden property on Tablix 2 to something like this

=iif(parameters!Bulyanhulu.value = '-1',true,false)

This ensure that on initial load, this details tablix2 is hidden.. it will show only when a value is passed to this parameter by clicking on textbox1

Good luck