I am new to the use of Pentaho and let me know how it works the "Calculated Columns" option into "sql query" object.
I need to calculate the average value.
Calculated columns perform basic operations on other columns, on a Row by Row basis. You cannot use that to calculate the average of all values from another column, but you can use it to calculate the average of values from the same row.
The syntax follows Open Formula syntax (the same you have on Pentaho Report Designer).
So, for example, if you have columns A, B and C as "Date", "Quantity" and "Sales", you can define a new column, "Unit Price" using the formula
=[Sales]/[Quantity]
Another situation is the following: lets say you have 13 columns: "Customer", "Jan", "Feb", "Mar", ...
You can create a new column, the Avg value of the 12 months, by either using the Avg function or summing all 12 values and then dividing by 12:
=AVG( [Jan],[Feb],[Mar], ....)
And the values of that new column would be the avg value of the 12 months per customer.
But each formula calculation will only use values from the same ROW or results, it cannot reference other rows of data.
Related
I have a raw dataset in excel like this
I'm trying to change some of the derived fields from Excel to SQL. I'm new to SQL and not aware of the syntaxes
as an example, column PY = (sum of column M*W where column B(2022-1 in this case), column C(site A in this case), column D(Flavor in this case) and column E(Americas in this case)/ sum of weight column where column B(2022-1 in this case), column C(site A in this case), column D(Flavor in this case) and column E(Americas in this case))
Please help me in the Prior year formula and can guide me in the right direction. basically it is making the calculations for the prior year same month.
Example Data Picture
My main data table is constructed in the following way:
1.State
2.Product
3.Account Name
4.Jan-20
5.Feb-20
.
.
.
N.)Recent Month- Recent Year
My goal is to get 6 total sums based on 6 different contiguous that are user selected. For example, if someone wanted the value of an Account Given a State and Product for FY-2020, they would sum columns 4 to column 15 (Twelve Months).
I am going to be running joins and queries off of the State, Product, Account combinations (first three columns), but I need to create a method to sum the Data table given a list of Column Numbers.
At this point, I am not looking to put non-contiguous columns in a selected Time Period (i.e. all time period selections will be from Col.Beg_TPn to and including Col.End_TPn). The Data Table houses monthly data that will have one new column every month. The Column Number should stay consistent as we are not looking back further than FY-2020.
This a much easier problem in Excel as you can do a simple SumIfs with an Index of the Column Range as the SumRange and then you filter on Columns 1,2,3. My data table is about 30,000 rows, so Excel freezes on me when could calculations and functions on the entire data set.
What is the best way to go about this in Microsoft Access? Ideally, I would like to create a CTE_TimePeriodTotals that houses the First 3 Columns (State,Product,Account) and then 6 TP Columns (tp-1,tp-2...) that holds the sum of each time period for each row based on the Time Period Column Starts and Time Period Column End.
I have a table with 3 columns in SAP Webi as shown in the picture.
In column "weekly average" I want to dynamically calculate the weekly average (from Monday to Sunday) of column "count".
Is it possible to do it with a variable? If not, any suggestions how to do it with other methods?
Thanks.
Yes, this can be done. Two steps: first create a variable to define a single value for each week, then another to return the average of those values.
For step 1, create a new variable ("Date Week") with the following definition:
=LastDayOfWeek([Date])
Then, in the report block (where your "Weekly Average" column is), create this formula:
=Average([Count]) in ([Date Week])
This should produce the result you want.
I have data that is broken into group totals (rows) and month totals (columns). I need to take the totals and calculate a value for each month within each group. From my screen shot I can find an monthly cell value for the quarter total with the formula
=INT($F3/3); this would ensure that all rows total correctly but does not address the requirement for all columns to total correctly.
For the screen shot I manually added the values to visualize the desired outcome
Group Calculation: (Jan+Feb+Mar)=Q1 group total
Month Calculation: (Group1...Group6)+Inventory = Monthly Total
In the "current result" screen shot the values total correctly by groups however the result is incorrect by month. For example 'Jan' totals to 159.
Current Result
I'm looking for assistance in a formula or vba that would allow the monthly values to total to the group and month total.
Desired Result
It sounds like you are looking to recreate a matrix from the totals of its rows and columns.
First, you need to remove the Inventory totals from the column totals, as those figures do not need to be calculated.
Then, you can get quite close to the answer with the formula =ROUND(RowTotal*ColumnTotal/OverallTotal,0). In this case, the formula in cell B2 would be =ROUND((B$8*$E2)/$E$8,0)
However, since there is rounding involved, you will notice that the values do not add up perfectly. For a matrix this small, your best bet would be to manually fix the problem values. To do so, add formulas to check which columns and rows are improperly totaled. Your check formulas should subtract the totals of each row and column from the desired row and column total. This reveals that cell B3 is the problem, as both column B and row 3 are misaligned.
You can change cell B3 to 48, which will then ensure that all columns and rows total properly. If you had a much larger matrix to solve, you could write some VBA code to automate the check of each column and row.
We're currently porting some excel reports to SSRS. One of those reports has a graph where the last column is the MTD (Month to date) average for both series (Availability and Availability Goal) just like the example below:
I did some research about RunningValue() but whenever I did it it would add a second bar to my graph (the running value would have the same group).
Is it possible to have only one aggregate column (just like the screenshot) ?
Thanks in advance,
One way would be to force the average through the SQL query. For example, if your resulting table shows days of the month, and the Availability value, you could UNION a "dummy" day (max days of the month + 1) with the averaged value. You can either add an addition column to your SQL for the label names, i.e. the "dummy" day would show "Average", or in SSRS you can change the Label expression to replace the last value with a text.