Forum Discussion
tomperro
Helper V
11 months agoUDF Question
I created a User Defines Function and it seems to be working but when I use it in a measure, it is retunring an incorrect value. Here is my function: function fnFYTDAverage = ...
- 11 months ago
It seems you missed a definition of the parameter. Refer to the function code below, please. The function can accept a measure in this way ": anyref expr" rather than considering it as a scalar. Please also refer to doc here https://learn.microsoft.com/en-us/dax/best-practices/dax-user-defined-functions#type
DEFINE FUNCTION fnFYTDAverage_new = (_measure: anyref expr) => AVERAGEX( DATESYTD(DateTable[Datekey]), _measure )
tomperro
Helper V
11 months agoYes, that ls what I have in the pbix, I updated my original post
DaleT
Resolver II
11 months agoIt seems you missed a definition of the parameter. Refer to the function code below, please. The function can accept a measure in this way ": anyref expr" rather than considering it as a scalar. Please also refer to doc here https://learn.microsoft.com/en-us/dax/best-practices/dax-user-defined-functions#type
DEFINE
FUNCTION fnFYTDAverage_new = (_measure: anyref expr) =>
AVERAGEX(
DATESYTD(DateTable[Datekey]),
_measure
)