[{"id":"bcb0874d-299b-448e-9552-9e9b25ef80dd","tags":[{"product":null,"links":null,"id":"ba7e818e-4f6b-4211-b1ac-58e3bafcf439","name":"\u66F4\u65B0","color":"orange","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"8ce3627e-9e58-471b-9133-4f135d191e7b","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"ae60ae59-34f5-4f32-a8eb-243ed1457543","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"3d4848c3-910f-4ffa-9153-60bb507334a9","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"133f4ca6-d951-4d65-a618-3dc6301266f7","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"de62ec1c-813e-40b1-8160-a4cd109afe64","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"2426c71d-8332-4cbd-a436-1ec4f8666464","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"2ce7b6b0-78aa-4e4b-bf8a-e4ba2f988298","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"4706db46-0811-4652-8f59-1e0a1da84758","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"8f1271bb-2cd9-4f39-9897-c15b239ee7ab","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"677e13a7-6f3e-449f-986c-2c3a26f8d54f","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"5e40f6dc-caec-49d7-a1d0-be65f06815ba","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"2457f0e0-9e71-4860-a87d-065e0fb84f84","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"d5c67fd0-1145-482c-9113-97b492c44c18","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"a609a8fa-ab91-4c1d-a1c3-d209d0463303","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"b4a9eb15-94e5-48df-b218-a24138f0cf9c","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]}]
        
(Showing Draft Content)

流程函数

流程函数用于控制表达式的计算过程。

Choose函数

以第一个参数为索引,返回后续参数中的一个。例如Choose(1,"a","b")返回字符串"a"。

IIF函数

最常用的流程函数,根据第一个参数的结果逻辑值(真/假),返回第二个或第三个参数的值。

语法形式:IIf(expr, truepart, falsepart)

参数描述:

  • expr:必要参数。用来判断真伪的表达式。

  • truepart:必要参数。如果 expr 为 True,则返回这部分的值或表达式。

  • falsepart:必要参数。如果 expr 为 False,则返回这部分的值或表达式。

IIF往往配合判断函数使用,例如:{IIF(IsDbNull(搭赠) ,0, 搭赠)} 可实现字段值为NULL时显示0的效果。

Partition函数

返回一个字符串,表示一个指定数值,出现在一个系列值中的哪一个区段。

语法形式:Partition(number, start, stop, interval)

参数描述:

  • number:必要参数。整数,在所有范围中判断这个整数是否出现。

  • start:必要参数。整数,数值范围的开始值,这个数值不能小于 0。

  • stop:必要参数。整数,数值范围的结束值,这个数值不能等于或小于 start。

  • interval:非必要参数。整数,数值范围的步长值。

比如Partition(230,1,1000,100) 返回字符串"201:300"。其含义是:从1开始至1000为止,每隔100为一个区间,230落在201-300这个区间内。

Switch函数

计算一组表达式列表的值,然后返回与表达式列表中最先为真的表达式所相关的数值或表达式。

语法形式:Switch(expr-1, value-1[, expr-2, value-2 _ [, expr-n,value-n]])

参数描述:

  • expr:必要参数。要加以计算的表达式。

  • value:必要参数。如果相关的expr表达式结果为真,则返回此部分的数值或表达式。

例如:

Switch( 月份 <4,1,月份 <7,2,月份<10,3,1=1,4)

可用于根据月份字段值,返回季度序号。

下面是一个更复杂的Switch函数示例:

Switch(
@period=0,Today()
,@period=1,DateAdd("d",1-weekday(Today(),2),Today())
,@period=2,DateValue(Year(Today()) + "-" + Month(Today()) + "-01")
,@period=3,DateValue(Year(Today()) + "-" + Switch( Month(Today())<4,1, Month(Today())<7, 4, Month(Today())<10, 7, Month(Today())>=10, 10) + "-01")
,@period=4,DateValue(Year(Today()) + "-" + Switch( Month(Today())<7,1, Month(Today())>=7, 7) + "-01")
,@period=5,DateValue(Year(Today()) + "-01-01")
).ToString("yyyy-MM-dd")

这是为了实现一种不同统计周期的需求:当天、本周、当月、本季度、半年、本年,选择不同的统计周期时,查询起始日期随之不同。