Forum Discussion

xuri's avatar
xuri
Frequent Visitor
9 years ago
Solved

Multiple use of the same calculation formula as a function for measures?

Hello,

I have a formula, which I want to use for multiple parameters. Defining the formula as a measure and using a filter for the parameters is not possible due to the data structure and an outer join. I have already tried this approach, but with a filter, I get the wrong values for the calculation. I only get the correct values, if I define the filters in separated measures for every parameter. Let's assume that the formula is
GetResult = (PARAMETER_2) / (PARAMETER_1 - PARAMETER_2)



What I have to do is:
Measure1 = (PARAMETER_2_Type1) / (PARAMETER_1_Type1 - PARAMETER_2_Type1)
Measure2 = (PARAMETER_2_Type2) / (PARAMETER_1_Type2 - PARAMETER_2_Type2)
Measure3 = (PARAMETER_2_Type3) / (PARAMETER_1_Type3 - PARAMETER_2_Type3)
etc.


Would it be possible to create a function which can be used for measures? I was thinking about defining a formula, which encapsulates the formula above into something like this: 
GetResult(PARAMETER_1_Type, PARAMETER_2)

This will not reduce the amount of measures, which I have to create, but I do not have to retype the whole formula x-times and it will reduce the risk of entering a wrong value in the formula. Is there a way to achieve this or is it only possible to copy the whole written-out formula and change the parameters?

Any hints and suggestions will be appreciated!

  • Anonymous's avatar
    Anonymous
    9 years ago

    xuri,

    The functionality that create custom DAX function is not supported in Power BI Desktop. An idea about this issue has been submitted in this link, please vote it up.


    You would need to copy the whole written-out formula and change the parameters.

    Regards,
    Lydia

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    xuri,

    The functionality that create custom DAX function is not supported in Power BI Desktop. An idea about this issue has been submitted in this link, please vote it up.


    You would need to copy the whole written-out formula and change the parameters.

    Regards,
    Lydia