[FileMaker] 如何在報表中按「月份」分類資料?

這也是朋友來信問到的問題之一:
如何在報表中按「月份」分類資料?

一開始我的想法很簡單,就是利用一個計算欄位 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)
  1. 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.
  2. Place the DateField into the Sub-summary part.
  3. 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″
  4. Place any needed Summary fields into the Sub-summary part. These fields will give you a separate subtotal for eachmonth.
  5. 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

主要技巧:

分開取得每筆記錄的「年份」跟「月份」,再組合起來呈現「年+月」,可以解決按月分分類資料的需求。

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com 標誌

您的留言將使用 WordPress.com 帳號。 登出 /  變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 /  變更 )

連結到 %s