Reading Excel Sheet in Guvnor Rule - drools

I have to take decision in guvnor rule based on some value in an excel sheet. So is it possible to do it in guvnor rule? Let me explain a simple example of what I want to do exactly:
Rule: Read average salary in particular country for a person. Than based on avg. salary compute other calculations in rule.
I will get person's country in input. Then I have to take that country and check in Excel Sheet for the average salary and perform calculations based on it.
Excel content:
Country Salary
IND $2000
USA $3000
CHN $1900
Now if the input is Person with country IND. So how can I read excel in guvnor?
Is it better to read excel in guvnor or read it in java code itself before calling the rule and adding it the value as one of the pojo field.
Any help much appreciated.

I would parse the xls file externally and insert the data as facts (or globals if you wish). So you you can write rules like:
when
Person($country: country)
AvgSalary(country == $country, $salary: salary) //This fact comes from the xls.
then
...
end
Another option is to encapsulate the parsing of the xls file and provide a mechanism to extract a particular salary for a particular country. In this case, you can provide that mechanism using a global and write rules like this one:
global XLSParser; // your parser class
rule "..."
when
Person($country: country)
$salary: Double() from XLSParser.getAvgSalary($country)
then
...
end
Hope it helps,

Related

Tableau converting dimension to measure

I have a technical question relating to Tableau. I have a Category field in the dimensions section which has three indicators: Disposable Income, GDP and Consumer Expenditure. I would like to convert 'Disposable Income' into a measure value on its own.
Is this possible to do?
I cannot share the Tableau data source due to data restrictions.
It is very easy. Add a calculated field named Disposable Income as-
IF [category] = 'Disposable Income' THEN [Measure_Val] END
Needless to say [Measure_val] is your measure field name here.
Alternate solution to your problem I propose here, but it needs reshaping your data altogether. I have created a sample data for explanation like this
select three years column and click on pivot.. you will get a view like this after renaming the fields appropriately
From here you can proceed as described above.

How can I use Crystal Reports record selection to choose from a list AND included a specific field

I am trying to figure out how to write a formula in the record selector that would allow me to select records in a specified list....but ONLY if there is also a specific record.
In My example. I am pulling earnings codes for employees from specific payroll transactions. For each Transaction date...each employee will have up to 10 codes.
I have my record selection set as this to narrow down the codes I want to see:
{UPCHKD.EARNDED} in ["01", "02", "BNSQT", "BVMT", "CASHBO", "FLAT", "HOL", "HOLPAY", "WAPFML"]
The issue is that I only want to see the first 8 codes IF there is also the WAPFML code. I can't figure out how to tell the record Selector to pick records that have BOTH WAPFML and any of those other 8 codes.
{UPCHKD.EARNDED} in ["01", "02","BNSQT", "BVMT", "CASHBO", "FLAT", "HOL", "HOLPAY", "WAPFML"] and
{UPCHKH.TRANSDATE} in {?Beginning Check Date} to {?Ending Check Date}
I hoped to see only checks where the WAPFML code existed. But I'm obviously returning checks that may not have that code. Using Group selection doesn't work as then I don't see the lines for the other codes.
Assuming you are grouping on {Employee_ID}, Add a group selection formula of MAX({UPCHKD.EARNDED}, {Employee_ID} ) = "WAPFML"
This takes advantage of the fact that "WAPFML" happens to be the largest alpha value in the set. If that is not the case, a more robust approach is to add the UPCHKD table a second time (with an alias), join on same Emp_ID to the first alias, and add a record selection condition on the 2nd alias forcing it to be "WAPFML"
OH I GOT IT! I was grouping by Employee and then transaction date. I entered Maximum ({UPCHKD.EARNDED}, {UPCHKH.TRANSDATE}) = "WAPFML" and took maximum of each transaction date and BOOM. Which now makes all the sense in the world. Thanks so much MilletSoftware for helping me!

To put two level of data in one tableau worksheet and aggregate them

I'm building up a supervisor scorecard on Tableau. Basically, there're two parts impacted on supervisor's score. One is supervisor's own performance, eg. there own's lateness. And the other part was their reporting employees' performance, eg. their employees' absenteesim.
My expectation is aggregating all the criteria in dashbaord, and filter supervisor's ID get his scorecard data. Here is a sample of the raw data:
So from the data we can know that for each CSR, they all have their supervisor, and for a supervisor, their reporting supervisor(which should be a manager) is blank.
So I created 3 calculation filed. One is called SUP_ID, and here's the code:
IF ISNULL([SupervisorID]) THEN [EmployeeID]
ELSE [SupervisorID]
END
Another calculation filed is called SUP_Flag, the code is :
[EmployeeID]=[SupervisorID____OLD]
The last one called SupervisorID___OLD], the code is:
IF [ROLE] = 'Supervisor' THEN [EmployeeID]
ELSE NULL
END
With these three calculation field, i'm able to use SUP_ID to filter all the information I want in each worksheet. When I want each supervisor's belonging employee's performance, I'll just use SUP_ID as filter. If I want each supervisor's own performance, I use SUP_ID as well as SUP_Flag to give me the information, and it works very well.
Everything above was done by separate worksheet.
Now my problem is:
There's a field that i need to put is called supervisor's final score, and it combines with both employee's performance score and supervisor's own performance score together in one filed. These two score are both in previous seperate worksheet. I'm thinking to use LOD to aggregate them, but it doesn't work as my expectation.
Here's what i wrote:
Final_Score_Part1(Sup's performance)
{FIXED [SUP_ID],[Supe Flag]: ([EVALUATION SC]*1* 0.2)}
Final_Socre_Part2(Employee's performance)
{FIXED [SUP_ID],[Supe Flag]: ((([LOST TIME %] * 0.6) + ([ATTENDENCE_SC]*0.2) + ([PUNCTUALITY_SC]*0.2)) * 0.5 )}
Final_Score:
Final_Score_Part1 + Final_Socre_Part2
Here's the screenshot that Tableau gave me.
(I've crossed out Supervisor's name)
So you can see that the part1 score was based on Sup_Flag = True, and part2 socre is based on SUp_Flag = Null, so when i aggregate them, it still won't give me the correct score.
Can somebody help me with this? I'll be so apprecaited for your help.
Thanks
Hi #Phani,
As i couldn't upload an image in comment, i've posted the new image here
enter image description here
For Final_Score_Part1(Sup's performance): include the condition
IF [ROLE] = 'Supervisor' THEN calculate the score[]
ELSE NULL
END
The same condition need to be used in Final_Socre_Part2(Employee's performance).

How to enable gender dependent salutation in phplist?

I would like to know who to enable/implement in phplist a sex-dependend salutation.
Eg. "Dear Mr. Michael Meyers" or "Dear Mrs. Eva Evangelista" depending on the "gender".
Did not find any possibility to do this.
Well, there's no such feature in PHPList per se.
But what you can do is add a new PHPList attribute called "salutation".
New subscribers will fill it up in the registration form.
For old subscribers, export the list to a spreadsheet, and add Mr. or Mrs. in each row*.
Finally, import the spreadsheet back to PHPList.
* An easier way to accomplish it is add a temporary column and write just 1 in it if the person is, for example, male.
Then in the real column do something like:
if(d2="1", "Mr.", "Mrs.")
Before you save it as CSV make sure to convert the real column from formulas into values, and delete the temporary column.

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.