Showing posts with label calculation. Show all posts
Showing posts with label calculation. Show all posts

Friday, March 23, 2012

Named Calculation, Referencing a field from a linked table

Is there a way to reference a field from another table in a named calculation.

Ex: Table movies has a link to table theatre, in the theatre there is a display code, the display-name of the movie should be comp.comp_displaycode + ' - ' + mov.mov_name.

I know i could do this in a view and than use the view instead of the movies table, but if it is possible in the Datasourceviews it would be easier.

Try replacing table in the DSV with named query joining 2 tables.

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights

|||This is very similar to defining views, i just hoped that there was a syntax available to do it.

Named calculation dataType

I have this expression in a named calculartion:

DATEDIFF("dd", [Date],[Maturity Date])/365

By default the datatype is INT? How can I have the result of the expression with decimal values? as 0,0974894 or 1,0008973 in spite of having 0 or 1.

Thanks!!

I have tried this, but doesnt work: :-(

CONVERT(NUMERIC(10,4),DATEDIFF("dd", [Date],[Maturity Date])/365)

CONVERT(DECIMAL(10,4),DATEDIFF("dd", [Date],[Maturity Date])/365)

|||

You need to convert the 365 as well.

Code Snippet

CONVERT(DECIMAL(10,4),DATEDIFF("dd", [Date],[Maturity Date])/ CONVERT(DECIMAL(10,4), 365))

Named calculation dataType

I have this expression in a named calculartion:

DATEDIFF("dd", [Date],[Maturity Date])/365

By default the datatype is INT? How can I have the result of the expression with decimal values? as 0,0974894 or 1,0008973 in spite of having 0 or 1.

Thanks!!

I have tried this, but doesnt work: :-(

CONVERT(NUMERIC(10,4),DATEDIFF("dd", [Date],[Maturity Date])/365)

CONVERT(DECIMAL(10,4),DATEDIFF("dd", [Date],[Maturity Date])/365)

|||

You need to convert the 365 as well.

Code Snippet

CONVERT(DECIMAL(10,4),DATEDIFF("dd", [Date],[Maturity Date])/ CONVERT(DECIMAL(10,4), 365))

Named Calculation - Incorrect Syntax near ','

Dear friends,

I have a problem with a named calculation!

The problem isqhen I use values with decimal... like 0,5 or 3,125 that you can see in the bottom of my NC...

Could you help me?

CASE
WHEN [Open Amount]<=0 THEN 0
ELSE
((CASE
WHEN [D_INST_TIPO_ID]=1 THEN
CASE
WHEN [Price/NPV] = 0 THEN [Avg Flash]
ELSE [Price/NPV]
END
WHEN [D_INST_TIPO_ID]=2 THEN
CASE
WHEN [Price/NPV] <> 0 THEN [Price/NPV]
ELSE
CASE
WHEN [Princ Cumul Flash]=0 THEN [Avg Flash]
ELSE 100
END
END
END
+ [Acrd Today])/100*[Open Amount]/[Fxrate Rep Cur]) *

(CASE
WHEN [Basel Weight]<>20 THEN [Basel Weight]
ELSE
CASE
WHEN (CONVERT(DECIMAL(10,8),DATEDIFF("dd", [Date],[Maturity Date])/ CONVERT(DECIMAL(10,4), 365)))<=0,5 THEN 3,125

END

END)
END

Hi Pedro,

Try use . against ,

cya

|||

Hello. If you use a dot(.) instead of a decimal(,) will it not work?

HTH

Thomas Ivarsson

sql