Adding new row in Crosstab Crystal Report - crystal-reports-2010

I would like to know if it is possible to add/place a row within a crosstab report.
For example, I am making a Profit and Loss Report using Crystal Reports 2011 for SAP. I would like to add a row below "Cost of Goods Sold Total" where I can place a row for Gross Profit which will be calculated from Income Total - Cost of Goods Sold Total.
(see attached image)
Let me know if this is possible. Any help appreciated.

For anyone who is facing a similar problem, I found a solution.
1) Right-click the 'Row' with the title '2' > Select Calculated Member > Insert Row. You should see a new Row with zero values below the row '2'.
2) Right-click the 1st blank space below '2' and select Calculated Member > Edit Header formula and type in:
"Gross Profit"
3) Then, right-click one of the zero values in the row and select Calculated Member > Edit Calculation Formula and use this code:
GridValueAt(GetRowPathIndexOf(1), CurrentColumnIndex, CurrentSummaryIndex) -
GridValueAt(GetRowPathIndexOf(2), CurrentColumnIndex, CurrentSummaryIndex)

Related

DAX Measure displaying values only for certain combination

setting up a SSDT in Visual Studio where I have masterlist with prices and 3 addtional attributes. These 3 attributes (Region, Customer, Material) can be used to to link the data to the other table with all the sales information etc.
Target: Showing the prices in a pivot if the 3 attributes are fulfilled and are matching to the other table with the same attribute combination. Assuming a calculated column is not solving the problem as this cannot display the price values in the value section of the pivot.
enter image description here
Please help me to find an appropriate DAX measure to link the data and show the prices for the matching attribute combination.
Thanks in advance :)
Masterlist with attributes which can be used as a key to connect to the other list?

Power Query, avg value based on the values appearing within a specified date range

Context:
I have a data set for the weights of truck and trailer combinations coming into my site over the span of a few years. I have organized my data by seasons as I am trying to prove that the truck:trailers in winter are noticeably heavier due to ice, snow, and mud. The theory is, if the tare weight is higher in this season (the weight of the truck after it empties its load) than its Avg tare weight (which I need to calculate from the data) it can be deduced that the truck:trailer combinations are coming in with extra weight that we pay for in part as some snow/ice/mud falls off in the trailer emptying process.
What I've done so far:
I've defined a custom date range for my seasons
I've grouped Truck:Trailer by: count to get a duplicates column and, all rows to keep all my details
I've filtered out every combination I've seen less than 50 times, as i want good representation for each truck:trailer combo so that I can better emphasize repeated patterns
I've added an index column to better keep track of the individuals before expanding the details
What I need to do:
I only want to work with truck:trailer combinations which have weighed in for all four seasons at least once
I need to find the average tare weight of the truck:trailer combinations based over the extended range for both summer and autumn (the dry time of the year) while preserving the raw tare data for all seasons, as I need to eventually compare the winter tare values to this average.
example of my data
When I'm finished I'd like the data to look something like this
Pivot Chart
query data
For your first question (all seasons) you can add a column that holds the distinct count of the values in [Season] for each [Driver:Trailer]. Then filter your table on that column, keeping only the 4's. To achieve this, add the following m-code to your script in the Advanced Editor. Change the part after in to #"DistinctCount Season"
#"DistinctCount Season" = Table.Join(#"insert name previous step","Driver:Trailer",
Table.Group(#"insert name previous step", {"Driver:Trailer"},
{{"DistinctCountSeasons", each Table.RowCount(Table.Distinct(_,"Season")),
type number}}),"Driver:Trailer")
Insert the name of your previous step where indicated.
For second question:
You can use a matrix-visual for that in you report. First create a measure:
[AverageTare] = AVERAGE(table'[Tare])
Then put [Season] on Rows and the [AverageTare] on Values. You can create a group (right-click on [Season] in the FIELDS-pain) called [DrySeason], to combine the values for Spring and Summer.
If that doesn't work for you, explore the AVERAGEX function.
EDIT
In excel you can use a pivottable. Put [Season] on Rows and the [AverageTare] on Values. Right-click a value in the pivottable. Select Value Field Setting and choose Average. Then select the Seasons you want to group, right-click and select Group.
EDIT 2
To add a column in the Power Query Editor that holds the average [Tare] for the [Season] in each row, add the following steps to your script in the Avanced Editor:
#"GroupedSeasonAvg" = Table.Group(#"Insert name previous step", {"Season"}, {{"AVG", each List.Average([Tare]), type number}}),
#"JoinOnSeason" = Table.NestedJoin(#"Insert name previous step",{"Season"},GroupedSeasonAvg,{"Season"},"AVGGrouped"),
#"ExtractSeasonAVG" = Table.ExpandTableColumn(JoinOnSeason, "AVGGrouped", {"AVG"}, {"SeasonAVG"})
It works something like this:
"GroupedSeasonAvg" : Creates a table with the avereges for each [Season]
"JoinOnSeason": Creates a new column with tables joining the [Season] value for each row to [Season] in the grouped table.
#"ExtractSeasonAVG": Expand each table and keep only [AVG].

Rank only for latest month

I've a calculated field "Total Revenue" which blends revenue from multiple data sources in Tableau.
Based on this field (aggregate field) on monthly basis, I would like to show only TOP 5 items with highest revenue as of latest month.
As shown in above table, items have to be filtered out (as they are TOP 5 in March) based on revenue data as of the latest month (March). How can this be achieved using RANK()? I'm not able to rank only for latest month as formulated below because it shows error as I cannot mix aggregate and non-aggregate functions.
IF DATETRUNC('month'),ReportDate)=//March 1st date given//
THEN RANK(Total Revenue)
END
My solution is a kind of workaround but seems to be working:
Create a calculated field with below formula:
IF DATEPART('month', {MAX([date])}) = DATEPART('month', [date])
and DATEPART('year', {MAX([date])}) = DATEPART('year', [date])
THEN
[revenue]
ELSE
0
END
The {MAX([date])} part on the code gets the maximum date in your data, it is fixed with { and } characters so that the value is not effected by the filters, date partitions etc. If you want the sorting month to be the one we are in then you should change that part with NOW()
Now we have a value containing only the sum of the latest month and we can sort our visual with this Measure.
You can drag your new measure (I called my measure: 'last month revenue') to the details and right click your item pill on the Rows, sort it by your new field.
And finally drag your item to the filters and go to Top tab, make filter your data according to sum of "last month revenue" measure.
Below screenshot shows the excel data and the final Tableau table:

Calculated Item in OBIEE - Moving Average

I have consulted this question - OBIEE Moving Average (Mavg) for 4 weeks on Pivot Table - in order to understand how to do a moving average in OBIEE. However, I am having trouble calculating that item in a pivot table.
In the pivot table view I thought I would just select New Calculated Item and create my moving average function for the pivoted values. Yet, in the "Values From" drop down menu the items I want to average are not present. I believe this may be because they are not extracted data values but previously calculated values from the data (in the original table's columns). I tried selecting "treat as attribute column" but this failed as well. How can I created a moving average within the pivot table for a column that was calculated from the original data?
Looks similar to this:
Pivot Table
ID Value
01 45
02 54
03 65
... ...
Where Value is Amount Sold / Days. And both Amount Sold and Days are stored in the original data table.
Go to the criteria tab and pull in a measure (any measure will do). Now edit that measure's column formula to your formula of Amount Sold / Days. I would rename it as well.
When you click over to the results tab, you will see that column added to all views. Just edit each view and remove the column from the views you do not want to see it in. You can also replace your existing value column in your pivot table (if it was present) with this new calculated column.
Pivot table calculated items are typically used in conjunction with columns that are already in the pivot table.

Business Objects XI Web Intelligence Aggregation Issue (11.5.8.897)

I've got a multiple tabbed report. On one tab I have the details listed and on another I have a summary table (cross reference) type of aggregation based on the same dimensions utilized in the detail report. I've created a calculated field that takes the product of two measures, I've saved this as a variable. When I try to aggregate that variable on the summary report BOWI is not calculating correctly. Example:
QTY * PRICE = LineTotal
2 * 3 = 6
4 * 3 = 12
TotalOrder = $18
Calculates correctly on the detail report.
When I put this on the aggregate report it is doing the following:
Sum QTY * Sum Price = Total, in other words it is doing
6 * 6 = $36.
My totals on the aggregate are highly inflated. Firstly in what world does that order of precedence make sense? and secondly how can I tell BOWI to sum the TotalOrders instead of breaking it back up into it's components summing those and then multiplying?
Is it a bug?
Further Information
The detail report is Sectioned by Year, Region, State -> Detail lines
The summary report is dimensioned by Year, Region, State
The (QTY * PRICE) component is saved as a variable and utilized in both places.
Am I missing the secret handshake somewhere when calculated fields/variables can't be aggregated and they need to do so in the Universe?
I havent worked with WEBI for a while, I mainly develop DESKI reports, however what you describe sounds similar to the aggregation that occurs in DESKI. If a measure is set to sum aggregation, then it will add all the measures together that relate to the dimension that is added to the report.
For example, if like my details reports, you have the columns order number, qty, price then the aggregation will sum both qty and price at the order level, which is correct. However moving to the summary table then this will cause incorrect data.
To remove the aggregation you can change it from SUM to NONE, I cant recall off the top of my head on how to do this in WEBI (if you cant find out I can check my course materials which are work).
Alternatively, it is best to ensure the dimensions on your summary report are suitable for the data presented.
If you need any further information please let me know.
Matt

Resources