I have the following code in SQL that I need to modify to Tableau native logic, preferably without the use of initial sql or custom sql. Whereas the following code is limited to one time period I need to use multiple time periods. See the line with the 'O' in it. I do not want to use custom sql because I have an existing dashboard with a lot of automatic aliasing already in use. Please advise.
SELECT
case
when T1.Source1 = 'nato' then T1.acc
when T1.MAST IN ('','note','lend') OR t1.MAST IS NULL then T1.ACC
else T1.MAST
end as ParNum,
case
when T1.Source1 = 'nato' then 'P'
when T1.sys = 'ac' then 'P'
when (
case
when T1.Source1 = 'nato' then T1.ACC
when T1.MAST IN ('','note','lend') OR t1.MAST IS NULL then T1.ACC
else T1.MAST
end)
= T1.ACC then 'P'
when (
case
when T1.Source1 = 'nato' then T1.ACC
when T1.MAST ('','note','lend') OR t1.MAST IS NULL then T1.ACC
else T1.MAST
end)
not in (select PARSENAME(t1.ACC,2) from cocoabutter where mokey=202203) then 'O'
else 'C'
end as ParFlg,
t1.*
FROM
cocoabutter t1