# 圖表運算式中輪替狀態機的範例

## 同步處理不同狀態的選項

count({\$} DISTINCT [Invoice Number])

count({State1} DISTINCT [Invoice Number])

count({State2} DISTINCT [Invoice Number])

count({State1<Year = \$::Year, Month = \$::Month>} DISTINCT [Invoice Number])

count({State2<Year = \$::Year, Month = \$::Month>} DISTINCT [Invoice Number])

QlikView開發人員將會讓 State1 和 State2 的年度和月份選項與預設狀態中的年度和月份選項保持同步。QlikView 開發人員可以視需要將元素新增到 set 修飾詞，以便讓狀態之間的更多欄位保持一致。

## 集合運算子

count({\$ + State1} DISTINCT [Invoice Number])

count({1 - State1} DISTINCT [Invoice Number])

count({State1 * State2} DISTINCT [Invoice Number])

## 隱含欄位值定義

set 運算子也可用於元素函數 P() 及 E()。這些函數僅適用於 set 運算式。

count({\$<[Invoice Number] = p({State1} [Invoice Number])>} DISTINCT [Invoice Number])

count({\$<[Invoice Number] = State::[Invoice Number]>} DISTINCT [Invoice Number])

count({\$<[Invoice Number] = p({State1} [Invoice Number]) * p({State2} [Invoice Number])>} DISTINCT [Invoice Number])

count({\$<[Invoice Number] = p({\$} [Invoice Number]) * p({State1} [Invoice Number])>} DISTINCT [Invoice Number])

count({\$<[Invoice Number] = p({\$} [Invoice Number]) * p({State1<Year = \$::Year, Month = \$::Month>} [Invoice Number])>} DISTINCT [Invoice Number])