简体   繁体   English

是否可以计算Tableau中计算字段结果出现的次数?

[英]Is it possible to count the number of occurrences of a calculated field's result in Tableau?

I have a function that categorizes calls a user has made into 3 categories using this calculation: 我有一个函数,可以使用此计算将用户进行的呼叫分类为3类:

    IF 0 <= DATEDIFF('dayofyear', [SubmittedDateTime], [CALLDATE]) 
    AND DATEDIFF('dayofyear', [SubmittedDateTime], [CALLDATE]) <= 7 
    THEN "Week After"
    ELSEIF -7 <= DATEDIFF('dayofyear', [SubmittedDateTime], [CALLDATE]) 
    AND DATEDIFF('dayofyear', [SubmittedDateTime], [CALLDATE]) < 0
    THEN "Week Before"
    ELSE "Not within a week"
    END

I was wondering if it's possible to count the number of occurrences of a particular outcome of the function on a per user basis in order to then categorize each user based off of the number of occurrences. 我想知道是否有可能在每个用户的基础上计算函数特定结果的出现次数,然后根据出现次数对每个用户进行分类。 I'm attempting to use this calculation to do so: 我正在尝试使用此计算方法:

    IF { FIXED [SUBID]: COUNT([DateDiff Calc] = 'Week After')} = 1
    THEN "1 Conference User"
    ELSEIF { FIXED [SUBID]: COUNT([DateDiff Calc] = 'Week After') } > 1
    THEN "Multiple Conference User"
    ELSE "0 Conference User"
    END

but the COUNT function I'm using is not working properly it seems. 但是我正在使用的COUNT函数似乎无法正常工作。 It seems that the COUNT function is also counting occurrences of both "Week Before" and "Not within a week" from the first function. 似乎COUNT函数也从第一个函数开始计数“ Week Before”和“不在一周之内”的出现。

I think the problem is the measure part of your LOD expression : 我认为问题是您的LOD表达式的度量部分:

 COUNT([DateDiff Calc] = 'Week After')

This will just give you count of both times: when your conditions is met and when its not met. 这只会给您两个时间计数:满足条件的时间和不满足条件的时间。 [DateDiff Calc] = 'Week After' will return true or false, both will be counted as +1 in the count function. [DateDiff Calc] ='Week After'将返回true或false,在count函数中两者都将被计为+1。

You could try something like: 您可以尝试类似:

IF { FIXED [SUBID]: SUM(IF[DateDiff Calc] = 'Week After' THEN 1 ELSE 0 END)} = 1 
THEN "1 Conference User" 
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM