Absolute Values in SSRS Report - reporting-services

I am new in SSRS reports and want to develop report in below mention format.
I want to get absolute values and then add.
i use the following query in dataset.
(Select S.Zone,S.City,H.EmpID,H.EmpName,H.Department,H.Designation,H.EmpDOL,H.JobLoc,Count(H.EmpID) as TotalStrength,0 as AvaStregth from HRData H
Left Join StoreTable S on H.JobLoc=S.StoreName
Group by S.ZOne,S.City,H.EmpID,H.EmpName,H.Department,H.Designation,H.EmpDOL,H.JobLoc
UNION ALL
Select S.Zone,S.City,NULL as City,NULL as EmpID,NULL as EmpName,T.Designation,NULL as EmpDOL,T.[Store Name],0,T.Value From HRTotalStrength T
Left Join StoreTable S on T.[Store Name]=S.StoreName)
Fomat in Excel

Related

Cascading Parameters Assistance - SSRS - VisualStudio

I have a cascading parameter setup for my report so that once I select a Client Number, it displays the Matter Numbers. I don't have a value for the client number set because we often search by the client number so it's easier to manually input that number in. The cascading parameter part works in that I type in a client number and received a drop down list of matters. However, when I click run report, it displays the details for ALL of the matters and not for just the one single matter I pick.
The main dataset has both parameters in the SQL as IN (#ClientNumber) AND IN (#MatterNumber). I've tried adding them as filters in the dataset properties, but that doesn't seem to do it either.
So the cascading parameters work in that I choose one and the next field ungreys and allows me to pick my next parameter, but then it just displays all data as if I hadn't picked a second parameter.
Any thoughts? I'm happy to provide whatever is needed.
--Including my query per request. I am using Microsoft SQL.
SELECT
HBM_MATTER.CLIENT_CODE,
HBM_MATTER.MATTER_CODE,
HBM_NAME.NAME,
HBM_MATTER.LONG_MATT_NAME,
HBM_PERSNL_ORG.EMPLOYEE_NAME AS Originator,
HBM_PERSNL_BILL.EMPLOYEE_NAME AS Billing,
HBM_PERSNL_RSP.EMPLOYEE_NAME AS Responsible,
HBM_CLIENT.OPEN_DATE AS [Client Open Date],
HBM_MATTER.MATTER_UNO,
HBM_CLIENT.CLIENT_UNO,
HBM_MATTER.MATT_TYPE_CODE AS [Area of Law Code],
HBL_MATT_TYPE.MATT_TYPE_DESC AS [Area of Law Description],
HBM_MATTER.OFFC AS [Office Code],
HBL_OFFICE.OFFC_DESC AS [Office Description],
HBM_MATTER.DEPT AS [Department Code],
HBL_DEPT.DEPT_NAME AS [Department Name],
HBM_MATTER.PROF AS [Practice Team Code],
HBL_PROF_CTR.PROF_CTR_DESC AS [Practice Team Description],
HBM_MATTER.STATUS_CODE AS [Status Code],
HBL_STATUS_MATT.STATUS_DESC AS [Status Description],
HBM_MATTER.OPEN_DATE AS [Matter Open Date],
HBM_MATTER.CLOSE_DATE AS [Matter Close Date],
TBM_MATTER.LAST_BILL_DATE AS [Matter Last Billed Date],
HBM_PERSNL_TIME.EMPLOYEE_NAME AS Timekeeper,
TBM_CLMAT_PART_BILL.EFF_DATE
FROM
HBM_MATTER INNER JOIN TBM_CLMAT_PART AS TBM_CLMAT_PART_ORG ON HBM_MATTER.MATTER_UNO = TBM_CLMAT_PART_ORG.MATTER_UNO INNER JOIN
TBM_CLMAT_PART AS TBM_CLMAT_PART_BILL ON HBM_MATTER.MATTER_UNO = TBM_CLMAT_PART_BILL.MATTER_UNO INNER JOIN
HBM_CLIENT ON HBM_MATTER.CLIENT_UNO = HBM_CLIENT.CLIENT_UNO INNER JOIN
HBM_PERSNL AS HBM_PERSNL_ORG ON TBM_CLMAT_PART_ORG.EMPL_UNO = HBM_PERSNL_ORG.EMPL_UNO INNER JOIN
HBM_PERSNL AS HBM_PERSNL_BILL ON TBM_CLMAT_PART_BILL.EMPL_UNO = HBM_PERSNL_BILL.EMPL_UNO INNER JOIN
HBM_PERSNL AS HBM_PERSNL_RSP ON HBM_MATTER.RESP_EMPL_UNO = HBM_PERSNL_RSP.EMPL_UNO INNER JOIN
HBM_NAME ON HBM_CLIENT.NAME_UNO = HBM_NAME.NAME_UNO LEFT OUTER JOIN
HBL_MATT_TYPE ON HBM_MATTER.MATT_TYPE_CODE = HBL_MATT_TYPE.MATT_TYPE_CODE INNER JOIN HBL_OFFICE ON HBM_MATTER.OFFC = HBL_OFFICE.OFFC_CODE INNER JOIN
HBL_DEPT ON HBM_MATTER.DEPT = HBL_DEPT.DEPT_CODE INNER JOIN
HBL_PROF_CTR ON HBM_MATTER.PROF = HBL_PROF_CTR.PROF_CTR_CODE LEFT OUTER JOIN
HBL_STATUS_MATT ON HBM_MATTER.STATUS_CODE = HBL_STATUS_MATT.STATUS_CODE INNER JOIN TAT_TIME ON HBM_MATTER.MATTER_UNO = TAT_TIME.MATTER_UNO INNER JOIN
HBM_PERSNL AS HBM_PERSNL_TIME ON TAT_TIME.TK_EMPL_UNO = HBM_PERSNL_TIME.EMPL_UNO INNER JOIN
TBM_MATTER ON HBM_MATTER.MATTER_UNO = TBM_MATTER.MATTER_UNO
GROUP BY
HBM_MATTER.CLIENT_CODE, HBM_MATTER.MATTER_CODE, HBM_NAME.NAME, HBM_MATTER.LONG_MATT_NAME, HBM_PERSNL_ORG.EMPLOYEE_NAME, HBM_PERSNL_BILL.EMPLOYEE_NAME, HBM_PERSNL_RSP.EMPLOYEE_NAME, HBM_CLIENT.OPEN_DATE, HBM_MATTER.MATTER_UNO, HBM_CLIENT.CLIENT_UNO, HBM_MATTER.MATT_TYPE_CODE, HBL_MATT_TYPE.MATT_TYPE_DESC, HBM_MATTER.OFFC, HBL_OFFICE.OFFC_DESC, HBM_MATTER.DEPT, HBL_DEPT.DEPT_NAME, HBM_MATTER.PROF, HBL_PROF_CTR.PROF_CTR_DESC, HBM_MATTER.STATUS_CODE, HBL_STATUS_MATT.STATUS_DESC, HBM_MATTER.OPEN_DATE, HBM_MATTER.CLOSE_DATE, TBM_MATTER.LAST_BILL_DATE, HBM_PERSNL_TIME.EMPLOYEE_NAME, TBM_CLMAT_PART_ORG.EFF_DATE, TBM_CLMAT_PART_ORG.PERCENTAGE, TBM_CLMAT_PART_BILL.EFF_DATE
HAVING
(HBM_MATTER.CLIENT_CODE IN (#ClientNumber)) AND (HBM_MATTER.MATTER_CODE IN (#MatterNumber))
This is a known bug in SSRS.
The only way I have found as a workaround is to create a hidden multi-select parameter that is based on the value selected in the first parameter, and on which the second parameter takes it's values from.
This solution is messy and confusing to any future maintainers if your documentation is not detailed and available, but at times inescapable.
I would recommend trying to find a way to have your selection criteria without the use of these cascading parameters.

Retrieve customer revenue

I want to create a report with the top 20 customers (based on revenue).
I am using the query:
SELECT dbo.CustTable.AccountNum
,dbo.dirpartytable.NAME
,dbo.hcmworker.PERSONNELNUMBER
,dbo.CustInvoiceJour.SALESBALANCE
,dbo.custinvoicejour.QTY
FROM dbo.CustTable
inner JOIN dbo.HCMWORKER ON dbo.HCMWORKER.RECID = dbo.CustTable.KEV_Worker
inner join dbo.custInvoiceJour on CustInvoiceJour.OrderAccount = CustTable.AccountNum
inner join dbo.dirpartytable on dirpartytable.recid = custtable.PARTY
where CustTable.KEV_Worker = '5633561745'
ORDER BY SalesBalanceMst DESC
I can't find the relation for the customer revenue, after all, that is how I want to sort the report. I am sorting on SalesBalanceMST right now while building the report. Also I am getting multiple records when executing this query.
What am i doing wrong?
EDIT: I now realize I am showing each Invoice Journal, how can I display the Total Revenue of the customer?
A similar search from AX 2012:
CustInvoiceJour CustInvoiceJour;
CustTable CustTable;
DirPartyTable DirPartyTable;
select forceLiterals generateonly sum(SalesBalanceMST), sum(Qty) from CustInvoiceJour
where CustInvoiceJour.OrderAccount == '102372200'
&& CustInvoiceJour.InvoiceDate > today()-365
join TableId from CustTable
group AccountNum
where CustTable.AccountNum == CustInvoiceJour.OrderAccount
join TableId from DirPartyTable
group Name
where DirPartyTable.RecId == CustTable.Party;
info(CustInvoiceJour.getSQLStatement());
This shows the following SQL:
SELECT SUM(T1.SALESBALANCEMST),SUM(T1.QTY),T2.ACCOUNTNUM,T3.NAME
FROM CUSTINVOICEJOUR T1
CROSS JOIN CUSTTABLE T2
CROSS JOIN DIRPARTYTABLE T3
WHERE (((T1.PARTITION=5637144576) AND (T1.DATAAREAID=N'xxx'))
AND ((T1.ORDERACCOUNT=N'102372200')
AND (T1.INVOICEDATE>{ts '2015-11-06 00:00:00.000'})))
AND (((T2.PARTITION=5637144576) AND (T2.DATAAREAID=N'xxx'))
AND (T2.ACCOUNTNUM=T1.ORDERACCOUNT))
AND ((T3.PARTITION=5637144576)
AND (T3.RECID=T2.PARTY))
GROUP BY T2.ACCOUNTNUM,T3.NAME
ORDER BY T2.ACCOUNTNUM,T3.NAME
What is different from your query:
no join on HcmWorker, as I do not have your custom field.
Using sum() to aggregate
selecting on InvoiceDate
selection on OrderAccount
selection on DataAreaId, really important for performance, implicit in AX
selection on Partition, really important for performance, implicit in AX
You cannot directly sort on a sum, but may on a nested SQL query.
I do not know exactly what is wrong in your query but perhaps this information can help you.
Check this standard report CustTopCustomersbyYTDSales, It has some good queries to do that.
https://technet.microsoft.com/en-us/library/hh389751.aspx

SSRS second parameter doesnot refresh after input first parameter

My SSRS report (2008 version) has two parameters. The first is a textbox receiving input for Supervisor' userid. The second is a drop-down list which depends on the first parameter to show the all the staff name working under the supervisor. After I input a supervisor userid for the first parameter, the second one does not refresh automatically. Then I press enter for the first parameter, an error message shows I have to select a value for the second parameter. My questions is how the second parameter can refresh automatically after I input the first parameter in the textbox.
Thank you very much for your help!
Are both your parameters as well as the Network_ID all INTEGERS?
It might work better if your first parameter was also based on a drop-down based on another dataset.
SELECT DISTINCT a2.Last_Name + ', ' + a2.First_Name AS Manager_Name, a2.Network_ID as Manager_ID
FROM Client_All c
INNER JOIN DimStaff d ON c.STF_NBR = D.ECMS_Wrkr_ID
INNER JOIN STAFF s ON s.STF_NBR = D.ECMS_Wrkr_ID
INNER JOIN ADPFile a ON s.FILE_NBR = CAST(a.FILE_NBR AS nvarchar)
INNER JOIN ADPFile a2 ON a2.Position_NBR = a.Supervisor_Position_NBR

distinct in query repeating values

I wonder if anyone can spot the problem with this 'view' query to show only 'company' and 'materials'. The problem is that it shows each entry a separate time for each material and company. I'm using this view to populate a dropdown box in a form but I would only like it to show the distinct values for each column (company/materials) - as of now if, for example, end result is the company 'Anderson' twice but with different materials for each...it shows 'Anderson' twice. I've tried using DISTINCT after the select statement for each of the two, but I don't achieve what I want.
select `b`.`company` AS `company`, `bp`.`material` AS `material`
from (((`caseys_wrdp4`.`windows_brands_products` `bp`
left join `caseys_wrdp4`.`windows_brands` `b` on((`bp`.`brand_id` = `b`.`id`)))
join `caseys_wrdp4`.`Windows_last_submissions` `ls`)
join `caseys_wrdp4`.`windows_materials` `wm`)
where ((`bp`.`width` = round(`ls`.`width`,0))
and (`bp`.`height` = round(`ls`.`height`,0))
and (`bp`.`material` = `wm`.`name`)
and (`bp`.`type` = `ls`.`type`)
and if ((`ls`.`minimumbid` <> '0.00'),
(`bp`.`cost` between `ls`.`minimumbid` and `ls`.`maximumbid`),
(`bp`.`cost` <= `ls`.`maximumbid`)))
Possible answer:
Add GROUP_CONCAT and GROUP BY to your query:
select `b`.`company` AS `company`, GROUP_CONCAT(`bp`.`material`) AS `materials`
from (((`caseys_wrdp4`.`windows_brands_products` `bp`
left join `caseys_wrdp4`.`windows_brands` `b` on((`bp`.`brand_id` = `b`.`id`)))
join `caseys_wrdp4`.`Windows_last_submissions` `ls`)
join `caseys_wrdp4`.`windows_materials` `wm`)
where ((`bp`.`width` = round(`ls`.`width`,0))
and (`bp`.`height` = round(`ls`.`height`,0))
and (`bp`.`material` = `wm`.`name`)
and (`bp`.`type` = `ls`.`type`)
and if ((`ls`.`minimumbid` <> '0.00'),
(`bp`.`cost` between `ls`.`minimumbid` and `ls`.`maximumbid`),
(`bp`.`cost` <= `ls`.`maximumbid`)))
GROUP BY(`b`.`company`);
This will give you back a single row for each company w/ company and materials. materials will be a comma-separated list (#Barmar). You could then parse that field for the 2nd drop down.
Example Rows:
'Anderson' 'Wood,Vinyl'
'WM' 'Metal','Plastic'
Assuming you're building a webpage, depending on how you're building the DOM, you can either use javascript str.split(), https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split, or on the server side, any language should work.

Leave out certain dates on Access report

I have a report in Access 2013 that prints an equipment log. There is a bunch of dates listed for each piece of equipment. I wanted to only print the newest date for each piece of equipment. I have searched the internet and this site with no luck. So any suggestions will be greatly appreciated.
My SQL statement is:
SELECT dbo_eq_location_transfer_d.equipment_id, dbo_equipment.description, dbo_eq_location_transfer_d.transaction_no, dbo_eq_location_transfer_d.job_no, dbo_jobs.description, dbo_eq_location_transfer_d.date_booked, dbo_eq_location_transfer_d.delivery_time, dbo_eq_location_transfer_d.line_no, dbo_eq_location_transfer_d.row_modified_by, dbo_eq_location_transfer_d.comment
FROM (dbo_eq_location_transfer_d INNER JOIN dbo_jobs ON dbo_eq_location_transfer_d.job_no = dbo_jobs.job_no) INNER JOIN dbo_equipment ON dbo_eq_location_transfer_d.equipment_no = dbo_equipment.equipment_no
ORDER BY dbo_eq_location_transfer_d.equipment_id, dbo_eq_location_transfer_d.transaction_no;
The date_booked field is the date field I am trying narrow down. I have a simple SQL query that works and I have been trying copy that into the about SQL but cannot seem to get it to mesh. It is:
SELECT [dbo_eq_location_transfer_d.equipment_no], Max(dbo_eq_location_transfer_d.date_booked) AS ["Newest Date"]
FROM dbo_eq_location_transfer_d
GROUP BY [dbo_eq_location_transfer_d.equipment_no];
In your query set the date fields criteria to:
>Now()-30
This will show any dates for the last 30 days just change 30 to the number of days you want to see.
Now that I understand your structure & data, here is what I did:
(1) Create the following query to select only the most recent 'date_booked' for each 'equipment_no'; save the query with name '23020071_A':
SELECT dbo_eq_location_transfer_d.equipment_no,
First(dbo_eq_location_transfer_d.transaction_no) AS FirstOftransaction_no,
First(dbo_eq_location_transfer_d.job_no) AS FirstOfjob_no,
First(dbo_eq_location_transfer_d.date_booked) AS FirstOfdate_booked
FROM (dbo_eq_location_transfer_d
INNER JOIN dbo_jobs ON dbo_eq_location_transfer_d.job_no = dbo_jobs.job_no)
INNER JOIN dbo_equipment ON dbo_eq_location_transfer_d.equipment_no = dbo_equipment.equipment_no
GROUP BY dbo_eq_location_transfer_d.equipment_no
ORDER BY First(dbo_eq_location_transfer_d.date_booked) DESC;
(2) I created the following query combining the new query with your existing query:
SELECT dbo_eq_location_transfer_d.equipment_id, dbo_equipment.description,
dbo_eq_location_transfer_d.transaction_no, dbo_eq_location_transfer_d.job_no,
dbo_jobs.description, dbo_eq_location_transfer_d.date_booked,
dbo_eq_location_transfer_d.delivery_time, dbo_eq_location_transfer_d.line_no,
dbo_eq_location_transfer_d.row_modified_by, dbo_eq_location_transfer_d.comment
FROM 23020071_A INNER JOIN ((dbo_eq_location_transfer_d
INNER JOIN dbo_jobs ON dbo_eq_location_transfer_d.job_no = dbo_jobs.job_no)
INNER JOIN dbo_equipment ON dbo_eq_location_transfer_d.equipment_no = dbo_equipment.equipment_no)
ON ([23020071_A].FirstOftransaction_no = dbo_eq_location_transfer_d.transaction_no)
AND ([23020071_A].equipment_no = dbo_eq_location_transfer_d.equipment_no)
AND ([23020071_A].FirstOfjob_no = dbo_eq_location_transfer_d.job_no)
ORDER BY dbo_eq_location_transfer_d.equipment_id, dbo_eq_location_transfer_d.transaction_no;
Now when I run the second query, it returns only the most recent row for that piece of equipment.