How to find group wise total(Sum) in SAP crystal report? - sql-server-2008-r2

How to find group wise total(Sum) in SAP crystal report?
Dear All,
I have to find the Sum of value based on the Date(01/01/2014……) And Regional (North,West,East,Central) wise….But 2014,2013 column data type varchar(25)
Here I will give little Example of what I want to do:
Date Regional StationName 2014 2013
01/01/14 North AAA 1000.00 100.20
01/01/14 North BBB 500.00 50.00
1500.00 150.2
01/01/14 West ZZZ 100.00 00.00
01/01/14 West YYY 500.00 10.00
600.00 10.00
Grand Total :2100.00 160.2

to get that done you will have to create 2 groups, one by Date(suppressed) and another by Regional where you are going to place all of your fields. Then crate to formulas, one for 2014 and another for 2013 columns to convert those strings to number using tonumber() function. For example tonumber(2014). Then you will have to summarize 2014 and 2013 based on Regional Group and grand totals for both as well.

Related

Q/KDB+ Create new column through a query

I have data in a table where there are "Buys" and "Sells" alongside the Quantity. I want query so that if it equals a "SELL" i multiply the Quantity column to negative. so far i am just selecting the data and taking from a certain timeframe. Nothing complex.
Using the update functionality along with the where clause you can edit a column in a table using certain filters. In this case the filter is where side=SELL.
If you add a backtick to the table name in the update statement this will update the table in place.
q)tab:([]time:10:00 12:00 13:00 14:00;side:`BUY`SELL`BUY`SELL;qty:300 400 300 500)
q)tab
time side qty
--------------
10:00 BUY 300
12:00 SELL 400
13:00 BUY 300
14:00 SELL 500
q)update qty:neg qty from tab where side=`SELL
time side qty
---------------
10:00 BUY 300
12:00 SELL -400
13:00 BUY 300
14:00 SELL -500
Updating in place:
q)update qty:neg qty from `tab where side=`SELL
`tab
q)tab
time side qty
---------------
10:00 BUY 300
12:00 SELL -400
13:00 BUY 300
14:00 SELL -500

Creating multiple graphs from single data table

I am trying to create a Google Spreadsheet for my sales for my business, that is happening on several different online portals e.g. Amazon, eBay, My Website, etc.
This is what I created:
But if I create this way then I do not get any graphs, which I really do need.
Though I tried other ways too, in which I had the portals in row 1 and dates in Column A, but in that case, I can have only one parameter, either No of Sales or Total Sales (rupees)
And the graph for this comes out nicely:
However, in this case, I would have to create separate sheet to record the Sales in Amount.
Is there a way to work this situation out, where I can create one table, and have graphs showing me the data as required as well?
This is a good application for Pivot Tables. Starting with your source data, you can either create pivot tables from the GUI (Data > Pivot Tables...) or by a formula using the QUERY function.
For example, this formula will create a table with portals in separate columns:
=QUERY(A:D,"SELECT B,SUM(C) WHERE A != '' GROUP BY B PIVOT A")
Note: A chart of this data requires that all cells be filled with numbers, so it's necessary that your source data includes zero values for portal/days with no sales, as shown in this sample data:
A B C D
Portal Date No of Sales Total Sales
Amazon June 18 33 45.62
Flipkart June 18 2 2.64
Biocarve June 18 3 4.32
Ebay June 18 0 0.00
Amazon June 19 22 37.01
Ebay June 19 2 3.52
Flipkart June 19 0 0.00
Biocarve June 19 0 0.00
Biocarve June 20 5 6.47
Flipkart June 20 1 1.45
Amazon June 20 8 10.69
Ebay June 20 0 0.00
The pivot table output is:
Date Amazon Biocarve Ebay Flipkart
6/18/2016 33 3 0 2
6/19/2016 22 0 2 0
6/20/2016 8 5 0 1
And the chart:
Likewise, this formula:
=query(A:D,"select B,SUM(D) WHERE A != '' GROUP BY B PIVOT A")
...tabulates the total sales, with this result:
Date Amazon Biocarve Ebay Flipkart
6/18/2016 45.62 4.32 0.00 2.64
6/19/2016 37.01 0.00 3.52 0.00
6/20/2016 10.69 6.47 0.00 1.45
You can also get all the summary data into one table, and produce a chart from that. (You need to customize your chart series to use left & right axes.)
The query:
=query(A:D,"select B,SUM(C),SUM(D) WHERE A != '' GROUP BY B PIVOT A")
The resulting table:
And an example chart from that table:

LOD Workaround with Tableau 8.3

I'm new to Tableau. I have a customer-event table to show which customers attended which events (like webinars, etc). One of fields is sales - which is the sales for that customer 30 days from the date of the event.
custid eventid eventdt 30daysales
1 aa jan 1 $100
1 ab jan 1 $100
2 aa jan 2 $150
Note that customer 1 attended 2 events on the same day. So the sales number is duplicated. If I were building a report for a single event, it's no problem. But when I build a monthly report, I want sum(Sales) = $250 and not $350.
My report sample:
Month eventcount customercount 30daysales
Jan 2 2 $250
With tableau 9, I read that using an LOD formula would allow me to sum sales on a per customer basis. But I'm on Tableau 8.3 and I'm wondering what the manual workaround is.
How do I write the calculated field to compute the 30daysales without duplicating?

Crystal Reports Conditional Grouping on Unrelated DB Field

I have some data in table SSTemp like this ("..." indicates data omitted for readability):
Month Year Number Gross Net
1 2013 1 1,000 500
2 2013 1 1,000 500
...
12 2013 1 1,000 500
1 2014 1 1,000 500
2 2014 1 1,000 500
...
12 2014 1 1,000 500
1 2015 1 1,000 500
...
12 2015 1 1,000 500
I am new to Crystal Reports and am using version 8 (no, we can't upgrade). I want to roll up the totals for all line items in years past and leave the data as-is for the current year in the same report. Database field {CONTROLFILE.CURRENTYEAR} contains the current bookkeeping year for our system which is vital to determine the rollup groups. The CONTROLFILE table contains general settings for the system and has no data in it useful for JOINing, however I need to consider CURRENTYEAR for the grouping. The MONTH column should be blank on the summary lines, and indicate month on the current year lines. The end result data should look like this:
Month Year Number Gross Net
2013 12 12,000 6,000
2014 12 12,000 6,000
1 2015 1 1,000 500
2 2015 1 1,000 500
...
12 2015 1 1,000 500
Any suggestions would be most appreciated!
Use sub report concept.
In main report calculate for previous years in sub report calculate for current year.
In main report group by year And suppress details show summary in group footer in another group footer section place sub report and just place data in detail part don't group

How to add multiple field values to a category expression in a chart using ireport?

I have a table which looks like the following
ID Name Year Jan Feb Mar Apr May [These are the column names]
1 abc 2012 2.5 3.2 2.5 2.3 6.2 [These are the values in the rows of my table]
2 abc 2011 3.9 6.2 7.5 6.5 6.8
I am trying to create a line chart where x axis is my column names i.e, Jan, Feb and so on and my Y axis should be its corresponding values. Series expression would be the year.
Could some one please help me in creating the category expression and value expression since I am unable to do so?
Any help would be appreciated. Thanks in advance.
Reformat your query output to be:
ID Name Year Month Value
1 abc 2012 Jan 2.5
1 abc 2012 Feb 3.2
...
2 abc 2011 May 6.8
Your month could also be yyyy-mm, which might help better organize your output. Then on the x-axis (category) use the month, and for the y-axis (value), use value.