Display all records that contain specific field. - combobox

I have a combobox with different project names. Projects might have more than 1 record belonging to them (so more than 1 record has a field with the same project name). I want to display all the records belonging to the project selected in the combobox.

This worked perfectly...
SELECT [Project Name], [Supplier], [Number of Tools], [Total cost]
FROM Quotations
WHERE [Project Name] = [Forms]![Quotations]![Combo0];

Related

SQL Server MDX Query: All Member accounts and Member Emails with = 0 minutes Using CROSSJOIN AND FILTER

I am new to SQL Server and am trying to get a query to show the members for all [Email] (i.e. User's E-mail Addresses) who have (null) values for the [Mins] field AND I also want a column for the user's [Account Name] (i.e. the company they work at).
Getting the query to run with the [Account Name] with ".Members" at the end is where I'm falling down. All three of these fields are on different tables, and I'm using a combination of CROSSJOIN AND FILTER.
I am not sure if the query won't run because:
I am using .Members incorrectly, since I'm using for both [Email] and [Account Name], OR
We have some sort of memory issues (which wouldn't be the first time!).
I am new to SQL and found different solutions on StackOverFlow for parts of the problem to successfully piece together the below code, but I've been unable to piece it together by adding ".Members" after "[Account Name]" The query runs but after a couple of minutes it runs out of memory.
If I don't include ".Members" after "[Account Name]", then the query runs successfully after about 17 seconds; however, it just shows "All" for Account Name, and it doesn't show the account. I simply want to show the Account next to Email!
'''
SELECT
[Measures].[Sum of Mins]
ON COLUMNS,
CROSSJOIN(
[vw_AccountData].[Account Name].Members,
Filter (
[vw_UserData].[Email].Members,
[Measures].[Sum of Mins] = 0
))
ON ROWS
FROM [Model]
'''
Expected/Actual Results
My understand is that for the users who have null values or zero values for this measure [Measures].[Sum of Mins you want their emailid and account name. I presume you have a measure [Measures].[Sum of Mins] and dimension attributes [vw_AccountData].[Account Name] and [vw_UserData].[Email] in your cube
Select
[Measures].[Sum of Mins]
ON COLUMNS,
filter
(
([vw_AccountData].[Account Name].[Account Name],[vw_UserData].[Email].[Email]),
[Measures].[Sum of Mins] = 0
)
on rows
from
[Model]

How to filter a crystal report by date?

I have created a crystal report using a command to view sales person vice Order count,their(orders) artworkpending count and detailpending count. It worked correctly.But i need to add a date filter to filer data.How can I add it?.I tried to add DocDate to command,but it duplicate sales person name according to DocDate. But I need to display all sales employees and their order counts.
Here my command query
SELECT Distinct
sp.SlpCode,
sp.SlpName,
sp.Telephone,
od.DocDate,
COUNT(od.DocEntry) count,
COUNT(CASE WHEN od.U_ArtWork = 'NotRec' THEN 1 END) AS Artwork,
COUNT(CASE WHEN od.U_DetailPending = 'No' THEN 1 END) AS DetailPrinting
FROM OSLP sp
LEFT JOIN ORDR od
ON SP.SlpCode = od.SlpCode
GROUP BY
sp.SlpCode,
sp.SlpName,
od.DocDate,
sp.Telephone
ORDER BY
sp.SlpName
Please give me a solution
Go to Report --> select formula --> Record and write below code:
DocDate = {your date goes here}

Is there a way to pull vendor creation date in Dynamics NAV 2016?

The business has a request for auditing to pull a list of all newly created vendors in NAV 2016 for a given period. I was unable to locate an entry creation date or added date for the vendor table. Is this possible? I'm currently supplying the business with the [Last Modified Date] which includes when a vendor has been added OR updated, but they want to only pull newly added.
My current code:
SELECT CAST([Last Date Modified] AS DATE) AS 'Last Date Modified'
,[No_]
,[Name]
,[Search Name]
,[Address]
,[Address 2]
,[City]
,[Vendor Posting Group]
,[Country_Region Code]
,[Post Code]
,[County]
,[Vendor Type Code]
FROM [Company].[dbo].[Company$Vendor]
WHERE YEAR([Last Date Modified]) = '2016'
and MONTH([Last Date Modified]) IN ('10','11','12')
ORDER BY [Last Date Modified]
,[No_]
If you do have the change log active, the following is a basic query that will get you all insertions to the vendor table:
SELECT
cle.[Primary Key]AS Vendor
, cle.[New Value]
, ven.Name
, CAST(cle.[Date and Time] AS DATE) AS LogDate
, CAST(cle.Time AS TIME(0)) AS LogTime
, cle.[Field No_]
, cle.[Type of Change]
, cle.[User ID]
FROM dbo.[YourCompany$Change Log Entry] cle
left outer JOIN dbo.YourCompany$Vendor ven
ON cle.[Primary Key] = ven.No_
WHERE
cle.[Table No_] = 23
and cle.[Field No_] = 1
AND cle.[Type of Change] = 0
ORDER BY LogDate, LogTime, Vendor
I'm also preparing a blog post on the change log which should be out next week.
If you don't have the change log active, then the options are
A. pull an old backup and compare.
B. Use something else to infer it.. e.g. find the first Vendor Ledger Entry for each vendor; you'll get a few false positives but might be enough to satisfy the auditors, if you reword their request and delivery "all vendors first used in October 2016 onwards".
Or use some info from your accounts dept. (they must have some record outside of NAV?) If you use sequential number series then you only need to identify the first in your date range.
Longer term, the you could talk to your Dynamics NAV partner and ask them to modify the vendor table to stamp the creation date/time. Although I would normally recommend running the change log on the Vendor Table anyway, as it's something auditors often want to see. I'd also always include the bank accounts table for the same reason.

How can I create a table that combines the date for multiple users even if it's null date for that user?

I'm trying to create a table that shows the history of every users purchase history. I have one table that shows the date, #DateTable and another table that shows each individual purchase with columns, "UserNumber" and "PurchaseDate" and "Purchaseamount"
How can I join these two together to get the sum of each users Purchaseamount for every single day, even if they don't make a purchase that day?
Maybe you can accomplish this by using only your second table?
SELECT UserNumber,
PurchaseDate,
(CASE
WHEN PurchaseAmount IS NULL THEN '0'
ELSE SUM(PurchaseAmount)
END) PurchaseAmount
FROM PurchaseTable
GROUP BY UserNumber, DAY(PurchaseDate)
If the above doesn't work, try modifying to WHEN SUM(PurchaseAmount) IS NULL...

SSRS BIDS Reporting Group By Header

Does anyone know how to make it so that when there are multiple records for a month (See image) there is only one line of data rather than splitting it into 4 boxes.
For example see June, I want this to have one box for RFC days and one box for Project days.
I have grouped by so far:
Row Groups - Service, MonthName
Column Groups - classification
You could do it by using grouping and sum the values at the group level and hide the detail line.
However, the easiest thing to do is do it in SQL using nested queries, like so (you probably also want to order by the month number rather than name, as shown below):
SELECT Service, Month(DateField) AS MonthNumber,
MAX(DatePart(Month, DateField)) AS MonthName,
SUM(ProjectDays) AS ProjectDays, SUM(RFCDays) AS RFCDays
FROM (
SELECT Service, DateField, Days AS ProjectDays, 0 AS RFCDays
FROM Project
UNION ALL
SELECT Service, DateField, 0 AS ProjectDays, Days AS RFCDays
FROM RFC
)
GROUP BY Service, Month(DateField)
ORDER BY Service, Month(DateField)
I found that I had to GROUP BY my MONTH field so I dragged this into the group by row groups, right clicked on it from here and in Group Properties added a group expression.

Resources