Crystal Reports group wise suppress field - crystal-reports

Name Rupees Company
Group 1st
A 50 A
B 70 B
C 45 C
Group 2nd
D 150 D
E 100 E
G 60 F
and I want the result
Name Rupees Company
Group 1st
A 50
B 70 B
C 45
Group 2nd
D 150 D
E 100
G 60
i want to suppress the Company filed on Maximum Rupees Filed and also Group wise.

Yo can write a supress condition of Company column.
Code looks something like this.
if(maximum(filed))=Group1 (Ruppes)
Then false
Else True
By this if the maximum of the required filed matches with the max of the group1 then the company part will display..rest of others will get supressed.
This should work
Let me know if you still face any issue.

Related

Utility like except for tables in kdb

As we have except function for lists in kdb to find the elements which are present in one list and not in another, similarly do we have any utility to extract the rows present in one table and not in another based on a column?
Eg: I have two tables:
l:([]c1:`a`b`c`d;c2:10 20 30 40)
r:([]c1:`a`a`a`b`b;c3:100 200 300 400 50)
Since, for column c1 in table l we have row c d which are not present in column c1 of table r.
Do we have any utility in kdb which can be used to get output like below?
c1 c2
-----
c 30
d 40
I got the output using -
select from l where c1 in l[`c1] except r`c1
But, I'm searching for better/optimised solution/utility to get the same output.
I don't think there's anything wrong with your current implementation but you could use drop (aka _) on a keyed table for a more succinct approach:
q)#[1#`c1;r]_1!l
c1| c2
--| --
c | 30
d | 40
This also remains pretty neat when they "key" is more than one column:
l0:([]c0:`x`y`z`w;c1:`a`b`c`d;c2:10 20 30 40)
r0:([]c0:`y`x`x`x`y;c1:`a`a`a`b`b;c3:100 200 300 400 50)
q)#[`c0`c1;r0]_2!l0
c0 c1| c2
-----| --
z c | 30
w d | 40
A more functional form would be this:
{cl:cols[x]inter cols y;x where not(cl#x)in cl#y}[l;r]
c1 c2
-----
c 30
d 40
This should work if you don't know the columns to match on because of cols[x] inter cols[y] at the start which obtains common cols between the two tables. It also works without columns being keyed.
Although in this specific case, the following would be a little bit faster:
l where not l[`c1] in r[`c1]

rank with LOD caculation in tableau

I have a table that looks liek this
column1 column2 value
a d 10
a e 20
b d 30
b e 40
and I want to get the rank of the value without considering column1 so I use and LOD to first get the total value with: {EXCLUDE [column1]: SUM([value])}
this works and produces
rank
d 40
e 60
d 40
e 60
BUT what I want to do is get the rank. So I'd like
rank
d 2
e 1
d 2
e 1
when I do this RANK( {EXCLUDE [Pct Of Adv Buckets]: SUM([Notional])} )
I get an error "all fields must be aggregate or constants when using table calcualtions. Can you advise how to get teh rank.
Did you tried RANK(SUM({EXCLUDE [Column1]: SUM([Value])}))
I have a different raking, but I think that is that you are looking for.

Getting a "The sum function requires 1 argument(s)." error

Trying to 2 values in a column together. The idea is that I get the m1, m2, and m3 values that fit the criteria; area ='000000' , ownership = '50', and code =113 or 114. The values should be 42, 40, and 44 respectively. Until now, I have been doing this in excel but am trying to take Excel out of this process. There are no NULL values involved in this.
Any idea why I am getting this error?
select sum (m1,m2,m3),
from dbo.tablename
where area='000000' and ownership='50' and (code='113' or code='114');
sample data
area ownership code m1 m2 m3
000000 50 113 40 38 42
000000 50 114 2 2 2
desired result
000000 50 113+114 42 40 44
In SQL, SUM(column) is an aggregate function that sums the values across different rows. If you want to add values from a single row, you can do SELECT m1 + m2 + m3 FROM.... You can also add the column values inside the rows, then sum it across rows like SUM(m1 + m2 + m3). I would re-write you query as:
SELECT SUM(m1) sum1, SUM(m2) sum2, SUM(m3) sum3
FROM dbo.tablename
WHERE area='000000' AND ownership='50' AND (code='113' OR code='114');
to get that specific answer as below.
desired result
area | ownership| code | m1 | m2 | m3
000000| 50 | 113+114| 42 | 40 | 44
once you want to see area and ownership this should have this columns on the sql and group by condition.
Like:
select area, ownership, sum(code), sum(m1), sum(m2), sum(m3)
from dbo.tablename
where area='000000' and ownership='50' and (code='113' or code='114')
group by area, ownership;

Tableau: A bar which shows the difference between

I have the following data for which i need to create a bar chart as shown in the picture in tableau:
Brand Sales week
A 12 1
B 20 1
C 14 1
A 12 2
B 22 2
C 16 2
A 18 3
B 16 3
C 27 3
My chart must contain sales in rows and week in columns. For every week, I must show three bars:
Sales for Brand A (A is always fixed)
sales for Brand B/ Brand C (B/C:- Its a parameter selection)
Difference between sales of these two
Is this what you asking for ??
You can do this by creating calculated fields of the sales for Brand A, Brand B/C (based on selection), and the difference between those two calculated fields:
Brand A Sales: SUM(IF [Brand] = 'A' THEN [Sales] END)
Brand B/C Sales: SUM(IF [Brand] != 'A' THEN [Sales] END)
Brand Difference: [Brand A Sales] - [Brand B/C Sales]
The calculation is dependent on your filter being setup properly, so make sure you have something like this calculated field in your filter card and set to True:
Brand Filter: [Brand Select] = [Brand] OR [Brand] = 'A' [Brand Select] is the parameter to select between B or C
Lastly, place [Measure Names] in the columns section and [Measure Values] in the rows section. Be sure only to include the 3 calculated fields mentioned above.
You should get a result like so:
Brand B -
Brand C -
Note: The calculation for the difference between brands may need to be altered based on your expected output. I based mine in the example off of what I assumed you had within the image in your post.

How to sum multiple elements from single record

I have table trade:([]time:`time$(); sym:`symbol$(); price:`float$(); size:`long$())
with e.g. 1000 records, with e.g. 10 unique syms. I want to sum the first 4 prices for each sym.
My code looks like:
priceTable: select price by sym from trade;
amountTable: select count price by sym from trade;
amountTable: `sym`amount xcol amountTable;
resultTable: amountTable ij priceTable;
So my new table looks like: resultTable
sym | amount price
-------| --------------------------------------------------------------
instr0 | 106 179.2208 153.7646 155.2658 143.8163 107.9041 195.521 ..
The result of command: res: select sum price from resultTable where i = 1:
price
..
----------------------------------
14.71512 153.2244 154.1642 196.5744
Now, when I want to sum elements I receive: sum res
price| 14.71512 153.2244 154.1642 196.5744 170.6052 61.26522 45.70606
46.9057..
When I want to count elements in res: count res
1
I assume that res is a single record with many values, how can I sum all of those values, or how can I sum first for?
You can use "each" to run the sum on each row:
select sum each price from res
Or if you want to run on resoultTable:
select sum each price from resoultTable
To sum the first four prices for each row, use a dyadic each-right:
select sum each 4#/:price from resoultTable
Or you could do all of this very easily, in one step:
select COUNT:count i, SUM:sum price, SUM4:sum 4#price by sym from trade
q)trade:([]time:10?.z.d; sym:10#`a`b`c; price:100.+til 10; size:10+til 10)
One caveat with take (#) operator is, if the elements in the list are lesser than the take count , it treats the list as circular and start retruning the repetative results. E.g. check out the 4th price for symbol b and c.
q)select 4#price by sym from trade
sym| price
---| ---------------
a | 100 103 106 109
b | 101 104 107 101 //101 - 2 times
c | 102 105 108 102 //102 - 2 times
Using sublist can ensure that it the elemnts are lesser than passed count argument , it will just return the smaller list.
q)select sublist[4;price] by sym from trade
sym| price
---| ----------------
a | 100 103 106 109f
b | 101 104 107f
c | 102 105 108f