Macro for sorting and Sumif - vba

In a worksheet, I have 5 columns, 1st column contain the file name. I have to split the file name in team,branch,location and week wise in preceding columns. after that have to apply filter and first filter on week from Oldest to newest then on location A to Z. I have 3 weeks data in each report. At the end of the last row, I want to add 3 more row of respective weeks and sum the respective weeks data.i.e eq. for 22-May-17, the next column should add only the data of the row of the same date.
table image

Related

how to create another dataframe from an existing one matching for multiple conditions

I have a dataframe that has around 8 million rows for housing data having values for zip, year and month for over 3 years. I want to create 4 separate dataframes for each year from this one that has columns for zip and month wise prices. In short I want to search for a particular zip for year 2019's January month and add the average price in front of it in another dataframe.

I created a new column in an existing table, now I want to group dates into that column

I want to group dates that fall within a particular range as week 4, week 5 .... and I want to have it in the new column I created in the table

Copy range to other worksheet if A1 contains specific word

I have 2 worksheets:
1st - for monthly data, where I collect data only for 1 month (1...12)
2nd - annually data by months (12 tables for each month)
I need macro which will copy data from monthly sheet to annually sheet according to month.
For example, if it`s September it will copy to September table in annually sheet.
If October to October table in annually sheet and so on.
How could I implement it using macro (want create button: click and copy).
The macro will need to include a CASE statement with 12 options (one for each month). Prior to reaching this CASE statement, you need to define a variable that will represent the month (e.g. using current date).
Each option within the CASE construct will copy from a specified sheet into a specified table (here I'm assuming that the structure of the monthly table are known and static).
An alternative approach would be to have the CASE setting the SOURCE sheet and the target range within the annual sheet. This would be a shorter piece of code using a common COPY block.

DAX Counting Values in previous period(s)

I have a Month Column with the Month Field populated for each line for the 100K of lines of data I have.
I need to count the amount of times the Month Field is populated in the Previous Month (Period).
I also need to count the total amount of times the Month Field is populated in the Previous 11 months as well.
This is a rolling count for each months reporting that I do..
table name: 'ws pds' and field name [Month Tagged]
You can utilize the powerful time intelligence functions in DAX such as PARRALLELPERIOD to look at values from previous months. But in order to make use of these functions you need to create a calendar/date entity. Mark that entity as a Date table. And join to it by date from your "ws pds" table. The Date dimension should span the timeframe of your date with a continuous list of dates, one row per day.
Then your measure could look like this:
PreviousMonthCount=
CALCULATE (
COUNTROWS ( 'ws pds' ),
'ws pds'[Month Tagged] <> BLANK (),
PARALLELPERIOD ( Calendar[Date], -1, MONTH )
)

Determine the column range of merged cells

My goal is to average a number of columns in one row.
The table is laId out by month, ONE week per column and a number of rows with the numbers in each column.
The table is divided into months across the top, with the month name header in a merged cell of four or five columns depending on how many weeks the month spans (Saturdays and Sundays are omitted at the start and end of the month leading to the four or five weeks per month).
For example, November this year (2015) includes five work weeks. The range of the header is O11:S11 - a merged cell.
Above this table that spans the year, there is a cell to average the number of hours spend on project time versus overhead.
In my example for November, I would average O43:S43. I would like to type or select the month to average in one cell, then find the column range of that month from the merged cells holding November.
For example, if the key cell is D9, holding November, and I want to place the average value in E9, and the row of months for the year spans from K11 - W11, what are the possible approaches to solving this question?
I tried using an INDEX MATCH formula but that gets me nowhere. I need to write a VBA function (I think).
You can find the merged cell then resize the range.Remove the rng.Selectline, it's just there to check if it is calculating correctly.
Sub Button1_Click()
Dim Fm As Range, Av As Range, rng As Range
Dim s As String, x
s = Range("D9").Value
Set Fm = Rows(11).Find(s, LookIn:=xlValues)
If Not Fm Is Nothing Then
Set Av = Fm.MergeArea
Set rng = Av.Offset(32).Resize(, Av.Columns.Count)
rng.Select 'remove later
x = Application.WorksheetFunction.Average(rng)
Range("E9").Value = x
End If
End Sub