Is it possible to calculate the moving average for 4 weeks in a separate column within the pivot shown here.
This is what I have:
http://i58.tinypic.com/2rraweo.jpg
Needs to have additional columns like:
http://i59.tinypic.com/30ti8ok.jpg
Side note: This is a union report and the "Total # of Submitted SRs" column is a sum measure from a fact table.
The answer was the function MAVG("column", 4) as long as the rows are defined by each week's count of "Total # of Submitted SRs".
Related
I am tasked with reproducing a spreadsheet in an SSRS report to save hours of Excel spreadsheet work. I have done all the calculations and got them into a single dataset however I am not able to work out how to display in the same table/matrix.
My spreadsheet looks like this:
Column B is a text column used to describe what the figures in each group are showing. Col C is 'Region' grouping.
I have got this far with my matrix - grouping by region and month. This gives me rows 3 to 8 incl of the spreadsheet.
But I am not able to work out how to add the next group of data (rows 9 to 12 in the spreadsheet) into the matrix. Each group of figures would use an expression to pull by a different field so only using single dataset: I still want it to use the region and month exactly the same as the top group. There is no parent or child relationship between the labels in col B in the spreadsheet.
I have tried adding an adjacent group below but it is still trying to keep it as part of the top group.
Is this at all possible?
do I need to have 6 different matrix, placing them together and just hide the month names in the bottom 5?
This is an extract of the data results. The top group counts the uniques customer id, the second group counts the unique sale id, the 3rd group totals the net sale value, the 4th group totals the profit value, the 5th group calculates the total sales and divides by the number of customers, the 6th group calculates the total sales and divides by the number of sales.
It looks like you will have to have 6 separate tablix and amend the aggregate function and field for each tablix
There are two tablix in ssrs report. I am using the same dataset for both tablix. First tablix which shows JOB details and $amnt BY Date (5 month worth of data) and second tablix shows records Grouped by Job and total of $amonts from tablix1.
Tablix 2 shows correct $Sum but for some records there are duplicate rows- if Tablix#1 has more than 1 $amnt.
Example Tablix1: ProjectABC - 1/1/2019 =$2 ; 1/5/2019=$5
ProjectHTG -1/1/2019 =$3
Exampl Tablix2: ProjectABC -$7
ProjectABC -$7
ProjectHTG -$3
how do i modify my expression "=sum(Fields!units.Value,"project2")"
to print "ProjectABC -$7" as one line?
Assuming that your field name if JOB for the project, you would add the field along with the dash to your current expression.
You should NOT group by amount if you want to SUM the amount. You are getting a separate line for each different amount for the same JOB. Only JOBs with the same amounts will be SUMmed as one.
=Fields!JOB.Value & " - " & sum(Fields!units.Value)
A few other issues:
Why are you using the Dataset name in your SUM? It sounds like you have a simple table that groups by JOB and Amount. The table is associated to the Dataset that you want to use. You should only use the dataset name in a table when you're referring to a different dataset than the table is using.
Why do you need two datasets if they have the same info? The second table can do the grouping and summing (and already is) from the same dataset as the first table.
Crosstab report works 99%.
About 20 rows, all but one are ok.
5 columns - Company Division.
The rows are things like cost, revenue, revenue 2, etc.
All the rows that work have three attributes I'm using to select them:
Fiscal Year
Period
Solution.
The problem is there is table that lists an YTD rate for each period. This table is not Division Specific; it's company wide.
All the tables are linked to the accounting period table that has fiscal year and period. So the overall query limits data to fiscal year (?pFiscalYear?) and period <= ?pPeriod?, based on prompt page results.
The source table has this:
FY_CD PD_NO ACT_CURR_RT ACT_YTD_RT
2018 1 0.36121715 0.36121715
2018 2 0.32471476 0.34255512
2018 3 0.25240906 0.31210183
2018 4 0.33154745 0.31925874
Note the YTD rate is not an average of any of the other numbers.
When I select the ACT_YTD_RT, as a row, I want the ACT_YTD_RT that matches the selected period.
What I get is the average if I set the aggregation to average or the lowest if I set it to other aggregations. So sometimes, it looks right (if I run for period 1,2,3, as the rate kept falling), and sometimes it's wrong (period 4
returns .3121 instead of .3192).
I've tried a number of different methods and can generate garbage data (totals, min, max, average) and crossjoins but can't figure out how to get the value I'm looking for.
I want YTD_RT where fiscal year =?pFiscal? and period = ?pPeriod?.
I tried a straight if then clause:
if (sourcetable.fiscalYear = ?pFiscalYear?) and (sourcetable.Period = ?pPeriod?) then (ACT_YTD_RT)
but I get an error like this:
'ACT_YTD_RT' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (SQLSTATE=42000, SQLERRORCODE=8120)
If I create another query that generates the right response and try to include it, I get a crossjoin error that the query I'm referencing is trying to crossjoin several other items in the crosstab query.
A union doesn't work (different number of columns).
Not sure how a join would work since the division doesn't exist in the rate table.
I maybe could create a view in the database that did a crossjoin of the division table and the rate table, add that to the framework and then I wouldn't have a crossjoin since the solution would be in the rate "table" (really view), but that seems wrong somehow.
If I could just write a freaking parameterized query direct to the database I'd be done. But in Cognos 11 crosstabs I can't find a place for a SQL query object. And that shouldn't be necessary.
I've spent hours and hours chasing this in circles.
Anybody have any ideas?
Thanks
Paul
So the earlier problem was that this:
if (sourcetable.fiscalYear = ?pFiscalYear?) and (sourcetable.Period = ?pPeriod?) then (ACT_YTD_RT)
Generated an error like this:
'ACT_YTD_RT' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (SQLSTATE=42000, SQLERRORCODE=8120)
To fix the above, I had to add a cross join of the division table and the rate table as a view in the database. Then add that to the framework. Then build the data item this way:
total (
if (sourcetable.fiscalYear = ?pFiscalYear?) and (sourcetable.Period = ?pPeriod?) then (ACT_YTD_RT)
)
And now the "total" provides the missing group by. And the crossjoin in the database provides the division information so the crosstab is happy.
I still think there should have been an easier way to do this, but I have a functioning hammer at the moment.
I am a senior developer but new to Pig.
We have a use case to construct a metric in Pig Latin as follows
Count of Customers who (purchased items month AND purchased items prior month) / Count of customers who purchased items in prior month
First step would seem to be to generate the customer counts with FOREACH GROUP GENERATE COUNT(Purchases); and write it to a file, then read it back in again
When i read the data back in again, is there a way in a for each to compare the current row (which would now be an aggregate count by month) and the previous row
Possibly the data should be pivoted before the data is written out and read back in again, and each column compared to the 'previous' going left to right instead of row by row?
can a case statement in pig have something like this
case (customerboolean_has_sales_february + customerboolean_has_sales_january)
2 countsalesfeb+ countalesjan/countsalesjanuary
1 null
0 null
Customers who rode in month AND rode in prior month / Total customers who rode in prior month
1)
Load the file twice into relation A and relation B.
Sort the relations A & B in sorted order of month.
Use RANK to generate row numbers.
From relation B remove the top record.
Use RANK on relation B to get new relation B_New
Join A and B_New on the row numbers.
For each row generate the result you want from the columns.
I've answered similar question here
2)
*can a case statement in pig have something like this?
case (customerboolean_has_sales_february + customerboolean_has_sales_january)
*
Yes.
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.