Dynamic column selection in Excel - dynamic

I have a table in excel with months as columns and couple of rows with data. I would like to add a column on the end of the table that will populate with data from the table as the YTD sum of the month columns. The YTD sum will be based on dynamic selection of the month selected from a list. Have a look at the attached image to see what I mean please, in the example Aug-16 has been selected in column P and the YTD total is returned correctly for this period (this is what I want to happen, but not sure how to?:
enter image description here
The dynamic selector I can do fine (Data validation -> list) but I'm not sure how to populate the column with the correct data, that is YTD for the month selected in the dynamic column added. Not sure if it can be done with MATCH, INDEX etc? I tried, also VLOOKUP, but not working....

One solution is to use this formula using the same parameters as your example image.
=SUM(C3:OFFSET(C3,0,MATCH($P$2,$C$2:$N$2,0)-1))

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.

How to filter an excel columns which contain date/time as string

I have an excel sheet to filter a Column. The column relates to total experience of a person. The values are like 5years 2Months, 32Years 6Months etc... all the values are in String format. I need the following functionality.
when i enter >5 in a textbox(which i will create in a form), it should display only experience which are less than 5(filtering) . I need an idea how to do this in vba.
Can anyone help..? I just need a way to do this.
Consider the following screenshot. Column a has the unfortunate text with years and months.
Column B splits out the years. Column C splits out the months. Column D has the total number of months for the time frame. With this in place, you can filter by any of the columns using the filter options of the Autofilter built into an Excel table.
The formulas are as follows:
Years: =MID([#total],1,FIND("Years",[#total])-1)+0
Months: =MID(SUBSTITUTE([#total],"Months",""),FIND(" ",[#total])+1,99)+0
Duration in months: =([#years]*12)+[#months]
Now just use the filters in the drop down butttons of the column headers and there is no need for VBA at all.

How can I get the Total field to display only once instead of on change of every group?

I have grouped my formula by my date field per month but why does it show in all the months (via lookup table)?
Perhaps there's something missing or wrong with my formula? This is its code:
(Sum ({tblDates.TotalFuelSales}) + Sum({tblDates.TotalMotorOilSales})) -
(Sum ({tblDates.TotalOperationalExpenses}) + Sum({tblDates.TotalMotorOilExpenses}) + Sum({tblDates.TotalFuelExpenses}))
Thanks!
Issue here is Sum ({tblDates.TotalFuelSales} will give you the grand total so for every date group you the same value... if you wish to get according to date grouping then your syntax shoukd be something like below.
Sum ({tblDates.TotalFuelSales}, {your date grouping})
Above is just an example check syntax when you apply... similarly apply to all fields in formula
If you dont you want to see the Total for each month then you should place #Profit formula on the Report footer. It is currently on the Group Footer section so it will show on change of every group.
I would do it this way:
1) Right click every field on the Group Header and Insert Summary (Sum) on the group footer for each field. So you have five Summary fields on the Group Footer section.
2) Put my Profit formula in the Report footer section, use those summaries in the formula to get my totals.
This is assuming you want Profit to appear only once.
You can skip doing the Insert Summaries part, and directly include the Sum({Fields}, {tbl.Date_group}) in your Profit formula.

Single aggregate column / running value sum on chart

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.

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