這也是朋友來信問到的問題之一:
如何在報表中按「月份」分類資料?
一開始我的想法很簡單,就是利用一個計算欄位 Caculation Field,將每筆資料的月份列出。(利用Function 函數:Month (date) 來操作)
Month:Month ( date ) Returns a number in the range 1 through 12, representing the number of the month of the year in which date occurs.
這樣可以計算出每筆資料資料日期相對應的月份數字,顯示 1-12 的一個月份數字。接著再利用這個計算欄位的值做 Sub-summary(但要記得按此計算欄位 sort 分類)就可以達成目的。
但是,這樣馬上會遇到一個問題:無法區分「不同年,同月份」的情況。
也就是說,「2015年8月」的跟「2016年8月」甚至未來「2017年8月」的資料將會歸類在一起。
於是 Google 查了一下怎麼解決這個問題,發現有個 FileMaker 網站所提供的方法不錯,在此記錄以便日後參考。 參考網址
[作法參考]
DateField (Date)
It is assumed that you already have a file named MonthSum.fp7 that contains the following field:
Given this, add the following calculation field to the file:
MonthSort (Calculation, Number) = Year (DateField) & Right ("0" & Month (DateField); 2)
- Create a new layout and add to it a Sub-summary part. In the Part Definition dialog choose Sub-Summary when sorted by: and highlight the MonthSort field.
- Place the DateField into the Sub-summary part.
- Format DateField using the Format Date command in the Format menu or use the Inspector in FileMaker 13. For example, you can make a customer date format that displays the date as “January 2003″
- Place any needed Summary fields into the Sub-summary part. These fields will give you a separate subtotal for eachmonth.
- Sort by the MonthSort field. Preview or print to see the results.Note: The field “MonthSort" need never to appear on any layout; it is only used to define the sub-summary and sort by