Home > Forum > General > Calculated Column in Report (V2025)

Calculated Column in Report (V2025)
0

Hi everybody.

I'm trying to implement a calculated column into a report.
This is the Query:
(
SELECT
dbo.ClearWFElemAdv(DET_Att3)
FROM WFElementDetails
WHERE DET_WFCONID = 9579
AND DET_WFDID = WFD_ID
AND dbo.ClearWFElemID(DET_Att1) = 1
)

This column is empty. If I put in a value for WFD_ID, e.g. 52750 the column is filled with the correct Value (for item 52750).

What am I doing wrong?

Kind regards
Klaus

You need to use wfelems.WFD_ID because WFD_ID alone isn’t recognized inside the subquery.
At that level, SQL doesn’t know which table the column belongs to.

By adding the alias wfelems (which i think refers to the V_WFElements view in the main query), SQL can correctly link both tables.
So the correct version is:

(
SELECT
dbo.ClearWFElemAdv(DET_Att3)
FROM WFElementDetails
WHERE DET_WFCONID = 9579
AND DET_WFDID = wfelems.WFD_ID
AND dbo.ClearWFElemID(DET_Att1) = 1
)