简体   繁体   中英

How to apply a filter in a calculated field?

I am trying to make a calculated field that would show the number of uploads. Our SQL programmer wrote this for me, as he doesn't know Tableau's syntax:

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]

This shows number of uploads grouped by date. What I would love to do is create a calculated field, which would display the same result, as applying filters and using CNT(date) to display number of uploads.

在此处输入图片说明

Any help would be greatly appreciated!

Well, I finally made it.

This is the correct syntax for a Calculated Field:

IF ISNULL([id_file_from])
AND ISNULL([id_user_from])
THEN [date]
ELSE NULL
END

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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