I'm looking to compare data that is from different time interval. I'm an Economics student and I'm trying to compare data that is released monthly and data that is released yearly. Specifically how the number of jobs created in a given month influences the GDP figure.
I'm neither allowed to post images or enough links with my current reputation so here's my beautiful collage to illustrate what I'm asking:
http://s22.postimg.org/jpspa1pvl/Screenshots.jpg
The frequency is different. The NFP (Jobs created) are released monthly, GDP is released yearly.
I'm wanting the GDP numbers to go at the start of the corresponding year. This is where I was having problems with VLOOKUP. I could't get it to align correctly or not repeat itself.
An illustration of the graph I'm after.
EDIT: To make it clearer
http://s15.postimg.org/qcg70u5aj/Screenshots1.jpg [ignore the graph]
Here's what I'm looking for without the dodgy formatting. So the first screenshot is the data. And the second is what I'm looking for.
The GDP data is released on the September each year, but it details the entire year of GDP growth. So I want compare it with the Job Figures (that are released monthly). So there will be 12 Job Figures (NFP) to each GDP figure.
Thanks.
PS: Sorry if there's similar questions. I don't know what keywords to search to get the answer.
I set up a sample worksheet as follows:
Column A, from Row 5 to 57 has dates: firsts of consecutive months 1/1/80, 2/1/80 etc
Column B, from Row 5 to 57 has random numbers for Non-Farm Payroll
Column D, from Row 5 to 17 has dates: Sep 30 of consecutive years 9/30/80, 9/30/81 etc
Column E, from Row 5 to 17 has random numbers for Annual GDP
Then I did this:
Column C, from Row 5 to 57: I added the formula =IF(AND(DAY(A5)=1,MONTH(A5)=1),VLOOKUP(DATE(YEAR(A5),9,30),$D$5:$E$17,2,FALSE),"")
Explanation
If the date in column A is the first of Jan (of any year), look up the 30th of Sep of same year in the GDP table and pick up the corresponding GDP value from the second column of that table ($D$5:$E$17). If not, leave the cell empty
Note
Once you have this modified to suit your purpose, you might want to copy those cells in Column C and do a paste-special (Alt-E, S) of them right back in the same place, pasting only the values so that the formulae are gone and you're not tied down to the GDP table.
Related
Let's say I have an excel spreadsheet recording some event that reoccurs often multiple times a day, sometimes not at all in a day. So I record the date and a bunch of other information for the event every time it happens. What I'm trying to find is, the average number of times this event occurs on each day of the week.
list of dates
So I want it to look at each day of the week, and find the average number of dates matching each day of the week, starting at the first date and ending at the last date. It should also take into account missing dates, so if there's a Friday with no records, that should affect the average occurrences for Friday.
I've tried using a Pivot Table to find this, and it can get me most of the way there, but it doesn't know to include missing dates within the "count of date" column.
pivot table
I'm not trying to find the average of some other value per day of the week, just the average occurrences of a date per the day of the week. Is this something that is possible in excel, or will I need to use scripts?
For an example where there's multiple weeks of data, I would expect to get a table of results like this:
Day of the week
Average
Mon
2.50
Tue
2.00
Wed
2.50
Thu
2.50
Fri
1.00
Sat
2.50
Sun
2.50
With Friday being lower as there is no Friday date in the provided range (the first Friday has 2 records, and the second Friday has 0 records).
We would need more data to really verify it (try it and let me know). You can use the following formula in cell D1:
=LET(A, A1:A14, B, B1:B14, wdays, TEXT(SEQUENCE(7), "ddd"),
cnts, COUNTIFS(B, wdays, A, TOROW(UNIQUE(A))),
ones, SEQUENCE(COLUMNS(cnts),,1,0), totals, MMULT(N(cnts>0), ones),
sum, MMULT(cnts, ones), HSTACK(wdays, IFERROR(sum/totals,"")))
Or you can use a more succinct formula via BYROW as follows:
=LET(A, A1:A14, B, B1:B14, wdays, TEXT(SEQUENCE(7), "ddd"),
cnts, COUNTIFS(B, wdays, A, TOROW(UNIQUE(A))),
HSTACK(wdays, BYROW(cnts, LAMBDA(x, IFERROR(AVERAGE(IF(x=0,"", x)),"")))))
Here is the output:
Note: If you want the result presented starting from Monday, then define wdays as follow: TEXT(SEQUENCE(7,,2),"ddd").
The name cnts, has the counts per week days (rows) and per columns (unique dates from column A). The rest is just to do the match to calculate the average. We ignore dates with no counts for calculating the average, as per my understanding of the sample input data from the question.
I am trying to make a bar chart with X- axis showing timeline with respect to months (Jan, Feb, March etc). On Y-axis, I want to count how many [KRI] are there in each month based on their [Status Category]?
I have two conditions though:
1) If [Status Category] is 'Final', count that KRI in all months between [TRIGGERDATE] month and [statchedate]. for example, same KRI should be counted in Jan, and Feb and March etc (from time it was open till the time/month it was closed).
2) If [Status Category] is NOT Final, count that KRI in all months between [TRIGGERDATE] month and today's month.
In the picture below with the data sample, the pink colored blocks shows when the KRI should NOT be counted in that particular month.
I am trying to write a custom expression using if statement, but I am not able to figure out how would spotfire know that a KRI should be counted between [Triggerdate] and [Statchedate]? Or for instance, between [Triggerdate] and [today]
I am also thinking about adding a calculated column that will determine if the KRI should be counted in how many months? (but this will be ongoing data, so I am afraid that my column would keep on expanding..)
Any suggestions would be very much appreciated :)
I have a bargraph which shows the quality of my data for each month. As the data is growing over the years, the graph is getting messy. So, i would like to show Avg Quality by year for all those months in Previous years but monthly for the current year.
Can any one help me how to achieve this.
Thanks,
-Dileep
This needs to be separated into two charts, or it just won't be legible. I'd suggest:
Creating an AVG by Year bar chart graph for all your data
Creating a details visualization of the above Yearly Average data which shows the 12 months of that year with SUM() as your aggregation method. Be sure to have YEAR > Month on your category axis
Thus, if you need to compare 1, 2, 3 or all the years by month you can select them all, or just the ones you want.
I was able to do it with the help of some calculated columns. To help explain, let's assume the value column in your data set is called Value and the date column in your data set is called ValueDate. I created some fictional data that extends into April, 2017 to help illustrate the solution.
Insert a calculated column to classify whether or not the date in each row is in the current year or not. I'm going to call the column DateGrouping.
CASE WHEN Year(DateTimeNow())=Year([ValueDate]) THEN "Monthly" WHEN Year(DateTimeNow())>Year([ValueDate]) THEN "Yearly" END AS [DateGrouping]
Insert a calculated column that tells us the last date of the month for ValueDate. E.g., if the date in the row is 4/10/2015, the last day of the month for the day in that row is 4/30/2015. If the date in the row is 7/8/2013, the last day of the month for the date in that row is 7/31/2013. We'll call this column LastDateOfMonth.
DateAdd("day",-1,date(Year([ValueDate]),Month(DateAdd("month",1,[ValueDate])),1))
Insert a calculated column that tells us the last date of the year for ValueDate. Of course, it's just Dec. 31 of ValueDate's year. Call this column LastDateOfYear.
Date(Year([ValueDate]),12,31)
Finally, we utilize the previous three calculated columns to add a calculated column for the date value we want to plot. You are wanting to plot by month for the current year, and by year for prior years.
CASE [DateGrouping] WHEN "Monthly" THEN [LastDayOfMonth] WHEN "Yearly" THEN [LastDateOfYear] END
On my value axis is the Value column, which I'm aggregating as an Average. On my category axis is the calculated DatePlot column -- I set the category axis to Categorical Scale. And I'm coloring by the calculated DateGrouping column to offer a visual cue that the data is aggregated differently over time.
Now, should this be done? There are certainly some pitfalls. You can't make the category axis Continuous Scale or else you'll see all the empty months when we're lumping prior years into Dec. 31. On the other hand, gaps are good visually when there is no data for a given period. So I don't know. But I pictured what you were asking and decided to try it. Buyer beware!
Trying to show a rolling average of pieces produced from the last 5 work days.
Currently I am tracking all days Mon-Sun and taking the last 5 days.
Here is my current formula:
=SUMIFS(AL:AL,AK:AK,">="&TODAY()-5,AL:AL,"<="&TODAY())/5
With AL:AL being the date column and AK:AK being the pieces produced.
I Can't figure how to arrange the data and dates to get my last 5 days average.
This is not difficult with a helper column. As you indicated in the question, the arrangement is important. First, organize your data with the most recent values at the top. So AL1 will always hold today's date.
In AM1 enter:
=IF(OR(WEEKDAY(AL1)=1,WEEKDAY(AL1)=7),"",1)
In AM2 enter:
=IF(OR(WEEKDAY(AL2)=1,WEEKDAY(AL2)=7),"",IF(SUM(AM$1:AM1)=5,"",1))
(column AM defines the values to be averages)
Then in another cell enter:
=SUMPRODUCT(--(AM1:AM10=1)*(AK1:AK10))/5
Some beginners place the most recent data at the bottom of a column. This usually make it more difficult to analyze.
I think your SUMIFS() function is incorrectly reproduced. The first argument is the "sum_range," the data to be summed, so that should be the number of pieces.
Also, you are getting 6 days including today. If you want 5 days (and if you have data for today), then you have to subtract 4 instead of 5.
You can accomplish what you want with this formula, I think:
=SUMIFS(AK:AK,AL:AL,">="&WORKDAY(TODAY(),-4),AK:AK,"<="&TODAY())/5
If you don't actually have data for today, then subtract 5 instead of 4.
This also depends entirely on your not having any data for weekend days. If you have production data for weekend days, then the averages will be off (they will include extra days).
If you have data for both weekdays and weekend days, you will have to use something like #garysstudent suggested.
I would like to generate a mock time series quarterly dataset from, say, 2000-2016 for a variable (quarterly credit growth) that averages around a certain value (say, 30%). Can anyone give a suggestion on how to do this in principle?
Edit: what I was implying were the actual data values for each time period, i.e. data with a certain mean and variance.
Found a solution with a code in Matlab, for anyone interested, see below in answers.
Excel approach:
You can make column A your date list. In A1, or A2 or more if you have header rows, you will have to seed your list by providing the first start date. Lets assume you put your seed date in A2. I would then go about adding 3 month to you start date using a formula, and copy down until you have hit your desired date. In order to add the 3 months I would use the following in A3.
=date(year(A2),Month(A2)+3,day(A1)
that will give you the first day of the month every 3 months. If you want the first day of the month every 3 months, set the day to 1 like so:
=date(year(A2),Month(A2)+3,day(A1)
And end of month could be calculated as:
=eomonth(date(year(A2),Month(A2)+3,day(A1)),0)
however I would prefer to do the end of month calculation based on the row you are in so I would do it more like:
=EOMONTH($A$2,(rows($A$2:A3)-1)*3)