[英]How to apply a filter in a calculated field?
我正在嘗試計算一個顯示上載數量的字段。 我們的SQL程序員為我編寫了此代碼,因為他不知道Tableau的語法:
select cast([date] as DATE) as [date], count(1) as number into #uploads
from files f with(nolock)
inner join files fr with(nolock) on fr.idl=f.id
where f.[id_user_from] is null and f.[id_file_from] is null
group by cast([date] as DATE)
select * from #uploads
order by [date]
這顯示了按日期分組的上傳數量。 我想做的是創建一個計算字段,該字段顯示的結果與應用過濾器並使用CNT(date)顯示上載次數相同。
任何幫助將不勝感激!
好吧,我終於做到了。
這是計算字段的正確語法:
IF ISNULL([id_file_from])
AND ISNULL([id_user_from])
THEN [date]
ELSE NULL
END
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.