So I'm working in microsoft sql server report builder and here is essentially what I'm trying to do in code:
(Under report variables)
vChargeStatusID = Lookup(Fields!CREDIT_CARD_TRANSACTION_ID.Value, Parameters!CREDIT_CARD_TRANSACTION_ID.Value, Fields!CHARGE_STATUS_ID.Value, "DataSet1")
(As an expression for a filter)
Lookup(Variables!vChargeStatusID.Value, Fields!CHARGE_STATUS_FK.Value, Fields!CONTRACT_NUMBER.Value, "DataSet1")
I've tried using the variable and the expression for the variable to try to create another calculated field, but no luck. I keep getting the error that I can't use nested lookup functions.
Basically what I'm trying to do is, first, find two things that are equal to each other to retrieve a number. Then I need to take that number and match it to something else to finally return the contract number.
I cannot figure this out.
Any help would be great.
So, a very simple way to accomplish this is to place a field on your report (TextBox1.value) that will hold your first lookup value.
For example, your first look up will return a vendor ID (DataSet2) from a customer order (DataSet1).
TextBox1.expression = Lookup(Fields!CustOrderID.Value,Fields!CustOrder_ID2.Value,Fields!VendorID.Value,"DataSet2")
But now you need to find the vendor name from a Vendor Master table (DataSet3). You can do another look up to the Vendor Master table using the ReportItems!TextBox1.value as the first value of the look up. That way you do not get the scope issue.
TextBox2.expression = Lookup(ReportItems!Textbox1.value,Fields!VendorID.Value,Fields!VendorName.Value,"DataSet3")
All credit goes to my boss who figured this out!
Step one: Create another dataset, which is embedded. This dataset then has a filter that takes a field, in this case it's CREDIT_CARD_TRANSACTION_ID, and evaluated it be true to the parameter, pCreditCardTransactionID. This makes sure that the second dataset is ONLY going to display to me the Contract number, which is the very last thing I needed from the Lookup Function.
Step two: Create an internal parameter that the default value is set to the field CONTRACT_NUMBER from the second dataset (ContractNumberLookup).
Step three: Create a filter on the table. The CONTRACT_NUMBER from the original dataset is set to equal the internal parameter.
Tada!
I hope this helps. If any clarification is needed, let me know!
Related
I want to do ARIMA_plus forecasting on a series of sale records. The problem is that sale records only contain sales. When doing the forecast we need to insert for every product the "non sales", which, essentially, are rows with the import column set to cero for every day the product has not been sold. We have here two options:
Fill the database with those zero-rows (uses a lot of space)
When doing the forecasting with ARIMA_PLUS in bigquery tell the model to fill with zeros instead of interpolating (default and seemingly unique option).
I want to follow the second option, yet, i dont see how. Here you can see a screenshot of the documentation Google info about interpolation
The first option would be carried out with a merge, nevertheless I would prefer to discard it since it increases the size of the sales table.
I have scanned the documentation and havent seen any solution
You need to provide an input dataset covering the missing values with the right method for your use case.
In other words, the SQL query must solve the interpolation so that the input for the model already contains the expected data.
You can, for example, create a query to add a liner interpolation solution for your use case.
So, the first approach you mentioned can be solved using that input SQL (rather than adding the data to the source table) and the second approach is not valid in bigquery, as far as I know.
Here you have an example: https://justrocketscience.com/post/interpolation_sql/
A little background on the report:
This is a productivity report for our employees working at our business. We determine their productivity based on the duration of the visits with clients. Some of our employees offer group sessions. They charge each client within the group, even though they are only giving, for example, one hour of service, they can bill for 10 hours if there are 10 people in the group. We determine what service they gave by service codes.
So, I have two fields in this formula, a service code field and a duration field.
The duration field is initially a STRING field from the database, even though it only gives number data, so I change it to a numberVar. The service code field is also a string field, and it sometimes does contain characters and numbers.
What I need Crystal Reports to do is take the sum of the duration. However, if the service code is, say, "1000", it must first divide the duration by 3 before summing it. This is where I get caught up.
Here's my code for the duration:
local numbervar num1;
If GroupName ({billing_tx_charge_detail.v_SERVICE_CODE})="1530" then
num1 := ToNumber({billing_tx_charge_detail.v_duration})/3
else num1 := ToNumber({billing_tx_charge_detail.v_duration})
Then I do a separate formula for the sum, named sumDuration:
Sum(#duration)
I get the error that this field cannot be summarized. After searching Google for two days I have found that Crystal cannot summarize fields or formulas involving constants. If I simply say:
local numbervar num1;
num1 := ToNumber({billing_tx_charge_detail.v_duration})
then I can summarize #duration. What am I missing? It has to be something simple, but I'm just not seeing it. Is there a way to create a custom function to accomplish what I am trying to get here? Or is it even simpler than that?
One person suggested creating a SQL command in order to do the calculations before the data gets to the report. I am a SQL newb so I had no idea where to even begin with that.
If you are grouping by Service Code and placing the above formula in the footer you will only be computing {billing_tx_charge_detail.v_duration} for the last record in the group. If you are intending to use the formula and sum the results and place the results in the Service Code footer try the following. (basically remove the reference to group name)
If {billing_tx_charge_detail.v_SERVICE_CODE}) = "1530" then
ToNumber({billing_tx_charge_detail.v_duration})/3 else
ToNumber({billing_tx_charge_detail.v_duration})
You can use variables (num1) if you want to but they are not needed.
You can still use the second formula you referred to and place in the group footer OR you can place the first formula in details section, right click and insert a summary to the group footer. You can also place in the report footer if you need it to total there as well.
I have a table full of clients in access and some are similar to each other (eg. NBC6, NBC10, etc.) I was wondering if there was a way to group all the similar clients and assign them all 1 ID. They would all start off the same so I was thinking to search for them like that but I'm unsure how to go about this in VBA. I am rather new to access and SQL so any help would be greatly appreciated!
Create a new field in your table called ClientGroup. Set its datatype to Text.
Get a list of all ClientGroup names you want to use. Let's say, for example, that NBC6 and NBC10 should end up in one group called NBC.
Run an Update query to assign that group:
UPDATE tblClients
SET ClientGroup = "NBC"
WHERE ClientName LIKE "NBC*"
The asterisk sign acts as a wildcard, so it will only update the records where the first 3 letters of ClientName are "NBC".
It's a lot of manual work, I suppose if you know you always want to use just the first 3 characters of a ClientName you can write a loop to put them in an array, but that's probably not the case.
it might be possible I'm searching for the wrong keywords, but so far I couldn't find anything useful.
My problem is quite simple: At the moment I get a list of individual Ids through a report parameter, I pass them to a procedure and show the results.
The new request is like this: Instead of showing the list for all individuals at once, there should be a list for each individual id.
Since I'm quite a beginner in srss, I thought the easiest approach would be the best: Create a subreport, copy the shown list, and create a subreport per individual id.
The amount of this IDs is dynamic, so I have to create a dynamic amount of subreports.
Funny enought, this doesnt seem to be possible. This http://forums.asp.net/t/1397645.aspx url doesnt show exactly the problem, but it shows the limit of the subreports.
I even ran trough the whole msdn pages starting http://technet.microsoft.com/en-us/library/dd220581.aspx but I couldnt find anything there.
So is there a possibility, to create a loop like:
For each Individual ID in Individual IDs, create a subreport and pass ONE ID to this?
Or is there another approach I should use to make this work?
I tried to create a 'Fake'-Dataset with no sql query but just for iterating the id list, but it seems the dataset needs a data-source...
As usual, thanks so far for all answers!
Matthias Müller
Or is there another approach I should use to make this work?
You didn't provide much detail about what sort of information needs to be included in the subreport, but assuming it's a small amount of data (say, showing a personnel record), and not a huge amount (such as a persons sales for the last year), a List might be the way to go.
I tried to create a 'Fake'-Dataset with no sql query but just for iterating the id list, but it seems the dataset needs a data-source...
All datasets require a data source, though if you're merely hard-coding some fake return data, any data source will do, even a local SQL instance with nothing in it.
I am trying to teach myself the new Tabular model for SQL 2012 SSAS to handle some analytic reports that were previously handled in (slow) stored procedures.
I've made decent progress on most of it, just figuring out how things work and how to add the calculations I need but I have been banging my head against the following:
I have a table that has file information -- it has:
ID
FileName
CurrentStatus
UploadedBy
And then a table that has statuses that the file went through (a many relationship to the file table):
FileID
StatusID
TimeStamp
What I'm trying to do is to add a calculated column to the File table that returns the TimeStamp information when a file was in a particular status. ie: StatusID=100 is uploaded. I want to add a calculated column called UploadedDate on the File table that has the associated TimeStamp information from the FileStatus table.
It seems like this should be doable with DAX but I just can't seem to wrap my head around it. Any ideas out there?
In advance, many thanks,
Brent
Here's a formula that should work for what you want to do...
=MAXX(
CALCULATETABLE(
'FileStatus'
,'FileStatus'[StatusID] = 100
)
,'FileStatus'[TimeStamp]
)
I'm assuming each file can only be in each status once (there is only one row per FileID that has StatusID 100). I believe you can just use a lookupvalue formula. The formula for your UploadedDate calculated column would be something like
=LOOKUPVALUE(FileStatus[Timestamp], File[FileID], FileStatus[FileID], FileStatus[StatusID], 100)
Here's the MSDN description of LOOKUPVALUE. You provide the column containing the value you want returned, the column you want to search, and the value you are searching for. You can add multiple criteria to your lookup table. Here's a blog post that contains a good example.