Forum Discussion
tomperro
9 months agoHelper V
UDF 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 = ...
- 9 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
9 months agoHelper V
Yes, that ls what I have in the pbix, I updated my original post
DaleT
9 months agoResolver II
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
)