LookupSet based on two fields combined instead of one - ssrs-2008

I have two datasets: Dataset1 (primary) and Dataset2. My report dataset is Dataset1.
I want to access Gross premium Amount from Dataset2 and put it in the report. The report is working just fine if the parameter for "market name" is a single value parameter.
When I set the parameter properties to "Allow Multiple Values", my report is displaying wrong Totals for "Production" Field. The problem is because the lookupset function is based on Currency_Type.
What I should do is search for each Market Name and for each currency type, then search for the appropriate Gross Premium in second dataset and return the value.
Dataset1:
Market Name Currency Type Receivable
Dataset2:
Company Name2 Currency Type1 Gross Premium Amount
The results should be like this:
Market Name Currency Type Receivable Gross Premium Amount
I used this code if to search for one value:
=code.SumLookup(LookupSet(Fields!Currency_Type.Value, Fields!Currency_Type1.Value,Fields!Gross_Premium_Amount.Value, "DataSet2"))
What should I do if I want the lookupset based on Market Name and Currency Type combined?

Can you join the datasets in your query? That would be a lot easier, if it's possible. Otherwise you need to have some way to break apart your multi-value parameter, such as a including it as an element in your first dataset. (Maybe even a cross join if appropriate.)
But to directly answer your question
What should I do if I want the lookupset based on Market Name and Currency Type combined?
[Note that this doesn't have much to do with how to lookup a multi-value parameter.]
I have solved this problem by creating a key from the two pieces of information in my queries themselves, such as with string concatenation, but you can also do the same in your LookupSet function:
=LookupSet(Fields!Currency_Type.Value +"-" + Fields!MarketName.Value, Fields!Currency_Type1.Value + "-" + Fields!Market_Name.Value, Fields!Gross_Premium_Amount.Value, "DataSet2"))
This will only work if MarketName is a value in your first dataset.

Related

How do I filter by more than one measure

I have a Word Cloud visual. The size of my words are determined by my total number of employees. Employees is its own field. Two other fields are FTE and Contract and they add up to my total employees. I want to filter my visual by either FTE or Contract. But when I drag these Measures under Filters and uncheck one, it results in no data displaying.
From your excel snapshot, it looks like you have a column for FTE and Contract. Since all records have a value for each column, if you "uncheck" one of them. All record will be filtered out.
From your question it appears you are trying to size the words based upon the number in either FTE or Contract (not total employees)? If this is the case, I would recommend creating a separate calculated field that toggles between the two fields based on a parameter value.
Ex. Calculated Field 1
IF [parameter] = "FTE"
THEN [FTE]
ELSEIF [parameter] = "Contract"
THEN [Contract]
ELSEIF [parameter] = "Total Employees'
THEN [Total Employees]
END
Ex. Parameter (String), List
Value Display As
FTE FTE
Contract Contract
Total Employees Total Employees

crystal report group on multiple criteria

This is a strange scenario that I'm having trouble working out:
I have a report that needs to show the summary of donations that each board member gave/got in any fiscal year. They get credit for hard credit donations, soft credit donations, and solicited donations. Meaning their record ID number is in 3 columns throughout the spreadsheet.
So, my data looks like this:
Soft Credit ID/Hard Credit ID/Solicitor ID/Gift Amount
1/-/-/$50
-/1/-/$100
-/-/1/$250
I need to be able to group these records together because they each have the ID # "1" in the record (but in a different column each time). I need to group these records together, so that it shows the summary for each board member, with the details below:
Board member ID 1: Total Giving $400
Soft credit - $50 - 4/1/13
Hard Credit - $100 - 3/29/13
Solicitor Credit - $250 - 7/2/13
(^These don't need to be summaries, this just needs to list all gifts and which kind of credit they give)
I'm having trouble because I don't see a way to group based on the ID, in different fields. I tried grouping based on a formula for each board member (formula read {Hard Credit ID}="1" OR {Soft credit ID}="1" OR {solicitor credit}="1") but it didn't work and it creates a hierarchy that I'm not looking for. Apologies for the formatting - I can't find instructions on how to make that block above appear as a table.
One way to do it, depending on your source DB, is to use a SQL Expression to condense the three fields:
coalesce({table.SoftCreditID},{table.HardCreditID},{table.SolicitorID})
Or you can do it in a regular formula:
if not(isnull({table.SoftCreditID)) then {table.SoftCreditID}
else if not(isnull({table.HardCreditID})) then {table.HardCreditID}
else {table.SolicitorID}
Replace nulls in the three fields with 0 and then concatenate. You will then have a possibility of three values in the new field: 100 010 001
If you concatenate the three ID fields into a new field without replacing the nulls then you will get "1", "1" and "1". If you replace the nulls with 0, then you will get "100", "010", and "001". Now, you can group-by on the new field and you will get subtotals, or skip-group-by and just list the detail. To extract the description of the code, if we are only talking about 3 possible values, you can use nested if statements to examine first value and test if it equal to "100", else test if equal to "010", else test if equal to "001", else error. Or a case statement, syntax examples here: Select/Case in Crystal Reports or Crystal Reports SELECT CASE statement

SSRS divide sum by a field

I'm trying to build a report which basically reports the number of closed incidents that a property has done in a given month then divide it by the number of beds in that property.
The number of incidents is calculated from the incidents table based on the month and the property then the number of rooms is obviously static per property.
The tables that I have a:
Incident: No_ which is the ID, PropertyID, Created_DateTime, Closed_DateTime, Status.
Property: ID, Name, No_of_Rooms
I tried this code in a calculated field but it errors saying that you can't use an aggregated column, which I thought it might:
=Sum(Fields!No_.Value, "Incidents")/Fields!No_of_Rooms.Value
I'm sure this will be simple but I can't find what to search to find the answer.
If this on the 'Details' level of the report and is commonly the lowest level. You may want this instead:
=(Fields!No_.Value / Fields!No_of_Rooms.Value)
If it is on a parent group I am guessing you just are listing a single instance and it wants an aggregate. In that case:
= (Sum(fields!No_.Value) / Sum(Fields!No_of_Rooms.Value))
This would perform aggregation on an aggregation. You do not need to do this (Fields!(thing).Value, "DataSet") if everything is in the same Dataset, if not then you do. Generally if are in the table or object that your dataset is referencing it knows that part implicitly without being listed.
Your formula will work but only if placed in the tablix but for performance this should be calculated in the query if possible.

FileMaker: Is there a way to build an export order in a script?

Question: Is there a way to build an export order while performing a script? I would prefer a FileMaker-native or FileMaker-called AppleScript solution, if one is possible.
Project: The project is a reporting tool which summarizes sales information (units, price, cost) by user-selectable criteria such as: week, quarter, year, location, product, supplier, etc. I would like a way to specify, at runtime, an export based on the user-selected criteria.
Example: If a user selected units sold summarized by supplier per quarter I would like to be able to have the script select:
Group by:
quarter
supplier
Export Order
quarter
units summary by quarter
supplier
units summary by supplier
There are obviously many permutations, so setting up an export for each individual export for each set of options is infeasible.
If the target format is text-based (i.e. tab- or comma-separated), then I'd export to XML and write a XSLT to summarize it as necessary. To pass parameters to the XSLT I normally export a small XML file to the same folder.
A solution I can think of is to export calculations rather than the original fields. With the example you give, assume that the user can export up to two fields. You create two calculation fields and two text fields. The text fields store the name of the field to export and the calculation fields use Evaluate (or GetField) to get the contents of the fields. It gets complicated if you're also exporting date and time fields, but it's still workable. If you need to include the field names in the export, you create an extra record and work your calculations for that record to contain the names of the fields the user has selected.
Not trivial, but still possible.
Building on Mikhail's and Chuck's suggestions, I think the best method for this particular project is going to be to build the contents of a .csv in a global field and then Export Field Contents. The basic outline of what I'm doing:
Go to the first record
Loop
WriteTheRows (see below), comma delimited, to a global field
Set $thisGroup to the count of records summarized by this summary field
Exit Loop If Get (CurrentRecord) + $thisGroup >= Get (FoundCount)
Go to record [Get (CurrentRecord) + $thisGroup]
End Loop
Export Field Contents [global field]
WriteTheRows is a custom function that does the following:
The output I'm trying to write can be sorted by up to 7 different criteria at the same time (for example: I could summarize supplier sales by quarter or I could summarize quarter sales by supplier)
Compare the highest level sort field's value to the last value we found for the highest level sort field.
If they're different WriteALine to the global field for this sort field, the next sort field, all sort fields down to the lowest level.
If they're the same, compare the (highest level sort field - 1) to the stored value for the (highest level sort field - 1)
If they're the same, WriteALine to the global field for the (highest level sort field - 1) on down to the lowest level sort field
... repeat until we're down to the lowest sort field
WriteALine is another custom function which adds the appropriate labels, commas and values using the GetSummary ( revenueSummary ; Evaluate ( "summaryField" & summaryFieldNumber ) as Chuck suggests in his answer.

creating a crystal parameter from a formula output

In my report there is a Purchasing Group number with values like 100,101,102....201,202,203..301,302,303... etc.
There is a formula to identify the Purchasing group department -
If {PURGRP} startswith '1'
then 'Purchasing Dept.'
else
if {PURGRP} startswith '2'
then 'Construction Agreements Office'
else
if {PURGRP} startswith '3'
then 'Storerooms'
else......
The report is grouped by these departments. i am trying to create a parameter which allows the user to select the Department by the names in the formula, but i am not able to append these names to available values as they are derived from a formula. One option is hard coding the values, but I was hoping there could be a more dynamic way.
My first thought was to capture all the department names in shared array, but I don't see any way to attach that to the parameter.
In all likelihood, having a separate lookup table in your main database is the simplest and least error-prone path. I suppose you could write a maketable query that would make your lookup table dynamic, but Crystal Reports isn't built for this purpose.