如何使用MS Access Expression计算多列中的唯一值,如下所示? I used Countif in Excel to get the "Yes" counts in the status column and now I want to use MS Access expression to get the same results.
答案 0 :(得分:0)
使用该函数进行行聚合。
把它拿出来
Public Function count_sum(col1 As String, col2 As String, col3 As String) As Integer
Dim count_yes As Integer
count_yes = 0
If (col1 = "YES") Then
count_yes = count_yes + 1
End If
If (col2 = "YES") Then
count_yes = count_yes + 1
End If
If (col3 = "YES") Then
count_yes = count_yes + 1
End If
count_sum = count_yes
End Function
使用以下查询
调用此函数SELECT col1,col2,col3, count_sum([col1],[col2],[col3]) as Status
FROM Table1;
你也可以使用这种功能。
在状态文本框中添加这样的控制源或直接使用上述查询并选择控制源作为状态。
=Nz(count_sum([col1];[col2];[col3]);0)