How to sum the values based on weeknumber & count the values greater than specific condition based on Weekn - data-visualization

I am trying to create a view that display items changes across a week.
The view tells 10 items changepercentage was postive,3 item changepercentage was negative and 4 item changepercentage no change during a week.
View details
To generate the view,my thought process was
Sum the values of the field based on the weeknumber
Count the values if <0,>0,==0 based on the weeknumber
But not able to figure the calculated field to find sum & count.
I am attaching the workbook
https://public.tableau.com/views/CountSum/SumCount?:language=en-GB&:display_count=n&:origin=viz_share_link

Related

Microsoft Access- How to create dynamic variables that queries a selection of Columns

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.

Calculate matrix of values based on column and row totals

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.

Crystal Report formula to reset a count?

I want to get the total qty of items sold by year by each part number. So far I have the following formula:
if {INVOICE_DATE} >= DateTime(2012, 01, 01) and
{INVOICE_DATE} <= DateTime(2012, 12, 31)
THEN Sum ({INVOICE_QTY)
Now, that formula just sums all the parts sold in that year. What I need is for it to reset the sum as it count through each invoice and by each part. How can I do this?
Your formula is not doing what you think it is. For each row in your report (I'll assume that this is by an Invoice_ID or something along those lines) this will simply display the grand total sum of {INVOICE.QTY} for all invoices in the report and will not change from row to row.
To get something that is like your image, you need to create a Cross-Tab object and configure it such that its rows are based on the Product_ID, the columns are based on Invoice_Date and set to be printed "for each year", and set the "Summarized Fields" to be the sum of {INVOICE.QTY}.
I guess you are not grouoing the report hence you are getting the grand total using that formula. What you can do is:
First create a group by Year and then by Part.
In details place your fields that need to be summed and supress the detail part.
Take sum in group footer 2 (For parts summary) and Group footer 1 (For year summary).

How do I compute an average of calculated averages in MS reportviewer/rdlc?

I've searched here and elsewhere on the web and have not found this exact problem/solution.
I'm building an rdlc report using the MS reportViewer - the report I'm creating is based on an existing spreadsheet where the average price across 6 months is calculated individually for each month, then the average of those prices is calculated as the 6 month period average price. Whether I agree with that methodology or if it's correct is irrelevant, I just need to know how to get an rdlc to do this.
For example:
Month Price1 Price2 Delta
May-12 $31.54 $30.03 $1.51
Jun-12 $36.27 $34.60 $1.67
Jul-12 $44.19 $42.00 $2.19
Aug-12 $38.96 $37.06 $1.90
Sep-12 $36.89 $35.08 $1.81
Oct-12 $35.57 $33.97 $1.60
Average $37.24 $35.46 $1.78
(sorry for the lack of a screen snip, I'm new and the system won't let me post an image...)
I've created a tablix that does the monthly averages computation - I use a group in the table to group the 6 months of data by month (and then hide the hourly price data so you only see the month total row) but I'm stuck on how to calculate the bottom row of the table which is the average of each column. (the average of the averages is not the same as the average of all 6 months of prices from the underlying data - that's what I've learned in this process... IOW, that was my first solution :-) )
What I tried to do to get the average of the averages was give the month total cell a name, MonthlyAvgPrice1, then in the bottom row, used this expression:
Avg(reportitems!MonthlyAvgPrice1.Value)
As I kind of expected, this didn't work, when I try to run the report, it gets a build error saying "The Value expression for the textrun 'Price1PeriodAvg.Paragraphs[0].TextRuns[0]' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers."
Hopfully I've explained this well, does anyone know how to do this?
Thanks!
-JayG
Actually it is not clear from the question that how are you in particular binding the data to the report items, But from the given information what I understand is that you can
Try like this:
Right Click the tablix row and insert a row below
In the cell where you want to have this Average of Averages insert the following expression
=Sum(Fields!Price1.Value)/6
and similarly insert expression =Sum(Fields!Price2.Value)/6 and =Sum(Fields!Delta.Value)/6 in the other cells where you want to display the Averages
Of Course, you will change the Field names Price1,Price2 etc to the fields that you are getting the values from.
HTH

How to group the formula field results in crystal reports

I want Number of cartons and Pieces currently available in the stock that are about to expire in next 30 days and this is calculated based on expiry date...I have used formula field on crystal report to calculate current stock like "stock.crtns_added - stock.crtns_removed" and "stock.pieces_added - stock.pieces_removed"....Now I want to group by item name, category and expirydate because based on these three columns there can be more than 1 entries in the database....I want that when there are more than one entries the formula should sum up all the cartons and pieces for same item of a category with same expiry date and on report it should display just 1 line showing available cartons and pieces that are about to expire
How can i do this?? How can I apply group clause on the formula field in crystal report to get sum of cartons or pieces for each item based on expiry date??
You can Insert Group for each group you want. You can nest the groups and put the formula inside the inner-most grouping and it should give you sums grouped how you want. You'll end up with something similar to this:
Report Header
Page Header
Group Header 1 (category)
Group Header 2 (item name)
Group Header 3 (expiry date)
Details
Group Footer 3 - summation formulas possibly go here
Group Footer 2
Group Footer 1
Page Footer
Report Footer