Complex Spotfire Join - left-join

I am attempting a complex join. I have tried a Left Outer, Left Single, Full, Inner, Right Outer and Right Single and none of them have produced the result I need.
I feel it might be easier to explain with Pictures so here it goes. In Pic 1 you can see my main Data Table Total Sales_2.
What I want to do is bring in the Value column from ROI RUBU Schema see Pic 2 for the corresponding Product on the corresponding Schema into Total Sales_2
So in Pic 1 you can see I have a line highlighted in green. It has its account number TY00009, its Schema Name ROI_RUBU_SCHEMA_8, the product number 156118, the product name, Estrumate 1x20ml 195, the Qty 10 and the Total Value 424.50
what I would like to see in the next column in Total Sales_2 is Value and 0.20 but I don't get that see Pic 3
I have used and a Left Outer join in this example placed on the Product code to bring in the Value Column from ROI RUBU Schema see Pic 2 into Total Sales_2
I was expecting to see 0.20 as I have a line highlighted in green in Pic 2 because ROI_RUBU_SCHEMA_8 gives back 0.20 for product 156118
As you can see in Pic 3 I get different values back for Product 156118 on ROI_RUBU_SCHEMA_8 See Pic 3
What I need is the value to be 0.20 for all on Product 156118 on the account TY00009 because its on ROI_RUBU_SCHEMA_8
If TY00009 was on ROI_RUBU_SCHEMA_9 I would expect to see 0.27 for Product 156118 as that is what ROI_RUBU_SCHEMA_9 gives back on Product 156118 again see Pic 2 ROI RUBU Schema
I have tried every join there is available and no luck. If anyone can offer any help it would be greatly appreciated.
Pic 1
Pic 2
Pic 3
So based on feedback from an administrator please find what I believe to be a useful amount of data that can be used to recreate what I am currently facing. If more data is needed I am happy to supply
Total Sales_2 Data
Customer Maxx name Customer Maxx Code Schema Name Product Code Product Description Sold Quantity Total Value
Random Customer Name TY00009 ROI_RUBU_SCHEMA_8 156118 Estrumate 1x20ml 195 10 424.5
Random Customer Name TY00009 ROI_RUBU_SCHEMA_8 119977 Rotavec Corona 1x40ml 125 30 5222
Random Customer Name TY00009 ROI_RUBU_SCHEMA_8 30179 Bovilis BVD 1x25ds 195 3 424.5
Random Customer Name TY00009 ROI_RUBU_SCHEMA_8 21406 Delvosteron 1x20ml 125 6 5222
Random Customer Name TY00009 ROI_RUBU_SCHEMA_8 13262 Dexafort 1x50ml 195 4 5222
Random Customer Name TY00009 ROI_RUBU_SCHEMA_8 156118 Estrumate 1x20ml 195 12 4444
Random Customer Name TY00009 ROI_RUBU_SCHEMA_8 119977 Rotavec Corona 1x40ml 125 32 3333
ROI RUBU Schema Data
Product Number Product Name List Price Oct 1st 2018 Category Value
156118 Estrumate 1x20ml 100 €28.50 ROI_RUBU_SCHEMA_8 0.2
156118 Estrumate 1x20ml 100 €28.50 ROI_RUBU_SCHEMA_9 0.27
156118 Estrumate 1x20ml 100 €28.50 ROI_RUBU_SCHEMA_10 0.16

So I finally got there, and I wanted to give the answer so that it may help others.
It was simple really and silly on my part. It was a left outer join that was needed, but I only bought in 1 Column Value from the ROI RUBU Schema table, so when I saw all the different values for ROI_RUBU_SCHEMA_8 on data table Total Sales_2 Data i thought the join was wrong.
If I had of also bought in the Category Column from ROI RUBU Schema table into Total Sales_2 I would of seen all the possible Schema. I simply did not bring in Category Column from ROI RUBU Schema table. Silly but it happened :-)

Related

Tableau stacked and side-by-side bar chart on column aggregation

I have a data set like this
Name Occupation Payment Principal Interest
Amy Nurse 100 90 15
Becky Teacher 80 100 20
Catherine Nurse 90 75 15
John Engineer 90 80 12
Tom Teacher 120 100 20
... ... ... ... ...
I'd like to create side-by-side(Payment) stacked chart:
Row: Occupations
Column1 : stacked(Sum of Interest and Sum of LP Principal) by occupation
Column2 : Only Sum of LP Payment by occupation
Can anyone give me hint how to make it?
Your data is not in the correct format for the required chart and you need to do some data prep.
Pivot all three measure fields from the data source page.
create a calculation to define the column for each data type
Build the chart as below and hide the header for column field.
One approach that avoids reshaping your data is to use the measure names and measure values placeholder fields to create the stacked bar chart.
See below

How to Sum values of column corresponding to one column in jasper

In jasper i have one requirement like, sum all the data of the column based on another column. I know how to show sum of all the data in the column. But please suggest me for this requirement.
Emp-Category Emp-Id Salary
---------------------------------------
Cate - A 1 128
2 50
3 89
total 267
Cate - B 4 123
5 50
6 100
total 273
Total Expenses 540
So there will be many number of categories, which will be getting from database.
Please suggest me how to do this approach.
In that case, you can use groups...
You can refer to the link below for tutorial :)
http://www.tutorialspoint.com/jasper_reports/jasper_report_groups.htm

Summing variable used in calculation after report is generated

I am creating a report where a query returns a list of values which are being used in my detail band. A new value shows for each record like it should. I'm trying to sum up these values and then use them in a calculation on the same line. Heres an example:
Color Fruit # of fruit Percent of total
--------------------------------------------------------
red apple 4 57%
green apple 3 43%
Total apples 7
The column being summed is the # of fruit or 3rd column. You can see the total at the end. Then the percent of total is the # of fruit for that row divided by the total. So for the first row it's 4 / 7 which equals 57%.
The problem is that I can't get the total until all the fruit has been summed. But I need that total to be used on each row for the Percent of total column.
How do I create a variable to do this?

Report Builder - Average of field if another field = X

I'm just beginning with Report Builder and I am trying to get an average of the value of one field if another field equals a number.
Example:
A table that contains a series of book reviews by different reviewers identified by number:
Reviewer Score
1 95
2 85
3 77
3 99
1 87
What I want is to get a reviewer's overall average score. So i would like to get an average of all scores filtering out the other reviewers.
I have been at this for a couple hours now and I don't think I am even close...
=Avg(iif(reviewer="1",score,Nothing))
I have used this successfully in my report.

Any other way to count group records in crystal reports?

I want to count the total no of records found under a group and according to that i need to assign reduction percentages.
In Detail,
if a user got less than 3 products he ll get 10%
if a user got 4-10 products he ll get 15%
if he got 10-20 products he ll get 20% as deduction
For example consider the following as a crystal report:
User 1
Product Deduction
Apple 15 %
Orange 15 %
Lemon 15 %
Strawberry 15 %
Grapes 15 %
Here i made a count of records in this group using running total and worte a formula. Depends on the count its ll make the deductions
But the problem in getting is, I'm getting the following output...
User 1
Product Deduction
Apple 10 % // Since count is 1
Orange 10 % // Since count is 2
Lemon 10 % // Since count is 3
Strawberry 15 % // Since count is 4
Grapes 15 % // Since count is 5
I wanna make all products deduction as 15 % if the total no of records are 4-15. Here the total no of products is 5 its in the range of 4-15 so all the product should have the deduction as 15 %.
Please help me out to solve this?
You don't need a running-total field (RT) for a simple count; use a summary field instead. The summary field can be used in the group's header and footer (a RT can only be used in the footer).
Select a field (preferably a unique field), then select Insert | Summary Field... Choose Count or Distinct Count from the picklist.
You can use this summary in a formula as well:
//{#discount}
//Assumes there is a group on {table.fruit_name}):
SELECT Count({table.key_field}, {table.fruit_name})
CASE 1 to 3: .1
CASE 4 to 5: .15
DEFAULT: 0