A very common challenge in corporate web reporting is determining the appropriate metrics for fiscal periods that differ from the calendar. This multi-part article discusses how we can use the Next Analytics Excel add-in to overcome our fiscal reporting challenges.
Let’s start with fiscal week reporting. Most fiscal weeks start on Sunday, and if that is your case, you can use Google’s definition of week for the reports (Sunday to Saturday). If your fiscal weeks don’t start on Sunday, then you’ll have to use the more advanced techniques as described for fiscal months and quarters in part II of this article.
Fiscal Weeks Starting on Sunday
The dimensions you use to break the queries into weekly buckets are ga:week and ga:year. The ga:week dimension is the calendar week number, starting at Jan.1st, but you have to combine it with the ga:year dimension to differentiate one year form the next. There is also the ga:nthWeek dimension, which is the sequential week number in the time period of the query, starting with 0. You can use this sequence number for weekly trend reports where you only need an increasing number for the x-axis of a trend chart.
Note that when you import the week, month, year, or nth week, the columns all contain numbers and Next Analytics may automatically interpret them as such (1, 2, 3, etc.). If you want to force them to be treated as text strings (01, 02, 03, etc.), go to the Columns tab, select the dimension and click the Text button.

If you concatenate the ga:year with ga:week, you can create a calendar year-week that can be mapped to a fiscal year-week number (e.g. 2010-32 becomes F2011-01). Caution: using the ga:week number can be problematic at the boundary from one calendar year to the next. Google starts the count at 1 on Jan.1st, even if it is the middle of the week. This means that the previous year would end in week number 53, which would also be a partial week (up to Dec.31st). This results in week 2010-53 being the same as week 2011-01, but the metrics are split across those two buckets. In a fiscal calendar, the week would normally be assigned to one year or the other, but it would not be split. Both rows of data would be mapped to the same fiscal week, and would need to be combined in the final report.

Mapping a calendar year-week to a fiscal year-week
In order to map a calendar year-week dimension into a fiscal year-week dimension, we start by concatenating the year and week columns into a new column using the ConcatenateTextColumnsscript command (from the Analyze tab).

At this point, we could use a brute force approach and use a series of ChangeTextInTextColumn commands to convert each calendar value into a new fiscal value. The challenge then becomes maintaining all those script commands over time.
ChangeTextInTextColumn,year-week,2010-14,2011-01
ChangeTextInTextColumn,year-week,2010-15,2011-02
ChangeTextInTextColumn,year-week,2010-16,2011-03
ChangeTextInTextColumn,year-week,2010-17,2011-04
...
If you are good at Excel, you could dynamically build those commands using some Excel formulas. As a general adage, though, it’s best if you don’t have to manually ‘mess with the code’ on a regular basis because, if you are not careful, Excel formulas have a way of breaking as things move around over time.
A better approach would be to create a lookup table on a separate worksheet, and use that to do the mapping. With Next Analytics, we can automatically save the lookup worksheet, load it into memory, and copy the fiscal equivalent column into our results.

The script command sequence to do all of this is shown below. It uses a calendar year-week combination mapped to a fiscal week from a worksheet named “Lookup” and maps that into your query results. As a final step, it combines duplicate rows to merge the split week at the calendar year boundary.
; make a single column of year-week from the separate year and week columns
ConcatenateTextColumns,year~week,-,year-week
SwapTextColumnWithRowLabel,year-week
RemoveColumns,week~year
PageCaption,Query Results
; save the Lookup worksheet and load it as a reference page in memory
uiSaveWorksheetToCsv,Lookup,lookup.csv
ImportDataFiles,lookup.csv,,0,1,,,,,
PageCaption,Lookup Worksheet
; get the matching fiscal week from the Lookup page
Select,Page, Query Results
JoinTwoPagesByMatchingRowLabel, Lookup Worksheet,fiscal
SwapTextColumnWithRowLabel,fiscal
; get rid of the calendar week and combine split weeks at the calendar year boundary
RemoveColumns,year-week
CombineDuplicates,Sum
Select,Column,Count
RemoveSelected
Using this technique, you can automatically map calendar weeks into their fiscal equivalent. On an ongoing basis, simply update the Lookup worksheet to extend the mapping between the two – the rest is automatic.
In part II, we’ll look at other fiscal and special period reporting, where the date boundaries do not have simple calendar equivalents.
Facebook Like and Comment Sources
On an Inside Facebook article this week, Josh Constine reveals how Facebook has recently improved the Facebook Insights API so it now reveals if page likes or comments came from a mobile device. With full access to the Facebook API, we thought we should show you how Next Analytics can pull this new information and make it readily available within Excel.
Using the FQL queries below, Next Analytics can make the queries to the Facebook API, which are available as daily metrics, and pull the results directly into Excel. In the example pictured above, we actually queried the past month and totaled the results using fully automated Next Analytics script commands to download and calculate the numbers for the column and pie charts.
SELECT metric, value FROM insights WHERE object_id=[FB_FAN_PAGE_ID] AND metric='page_like_adds_source' AND period=period('day') AND end_time=end_time_date('2011-12-31')SELECT metric, value FROM insights WHERE object_id=[FB_FAN_PAGE_ID] AND metric='page_comment_adds_source' AND period=period('day') AND end_time=end_time_date('2011-12-31')The workbook can be downloaded here and requires Next Analytics add-in for Excel to automate the API queries.