Home > Forum > General > Calculated column – how to reference the current WFD_ID?

Calculated column – how to reference the current WFD_ID?
0

Hi everyone,
I have a question about calculated columns in reports.
I'm using a query similar to the one below:

SELECT
CASE
WHEN EXISTS (
SELECT 1
FROM TableA A
JOIN TableB B ON ...
JOIN TableC C ON ...
WHERE GETDATE() BETWEEN DateFrom AND DateTo
)
THEN 'YES'
ELSE 'NO'
END

Is it possible for the calculated column to refer to the current report row/element using a parameter or placeholder?

For example, something like:
WHERE WFD_ID = ##CURRENTID## or WHERE WFD_ID = ##WFD_ID##

Is there a supported parameter that represents the current element's ID in a calculated column, or is there another way to achieve this?

Thanks in advance!

MVP

Hi Anna,
you can use diagnostic tools, to record what happens when a report is being loaded and specific query that is being sent to database.
In that query you will find V_WFElements aliased as wfelems.

In case of your example you have to create a correlated subquery, and in that WHERE, there should be a WFD_ID = wfelems.WFD_ID.

An example from my environment:
(
SELECT
dbo.ClearWFElem(WFD_AttChoose1)
FROM
WFElements JOIN
WFSteps ON WFD_STPID = STP_ID JOIN
WorkFlows ON WF_ID = STP_WFID
WHERE
WF_GUID = 'some guid' -- this is not necessary in most cases, but in my case it improved join speeds
WFD_ID = wfelems.WFD_AttChoose4_ID (in this case i had attribute, but wfelems.wfd_id will works too)
)