Forum Discussion

mcraven1845's avatar
mcraven1845
Frequent Visitor
7 years ago
Solved

custom function creates but expression error when add column/invoke custom function getting

I created a custom function to get the Year part of a date and then use that custom function inside of another more complex function.  Both functions create successfull but when I try to add column, ...
  • mcraven1845's avatar
    mcraven1845
    7 years ago

    Hello, Thank you for your offer to help.  Chris Webb from Cross Join was able to help me.  I'll include the solution below for others to benefit from.

     

    The correct and successful function is as follows - 

     

    let Fiscalyr1 = (UpgradeRpDate,CurrentMaint,UpgradeCost) => if Date.IsInCurrentYear(Date.Year(UpgradeRpDate))=Date.Year(UpgradeRpDate) then

                                                                     CurrentMaint+UpgradeCost

                                                                else CurrentMaint

    in Fiscalyr1

     

    I was using square brackets incorrectly in the original one.  You use square brackets when you’re calling the function because you’re getting values from the various columns on the current row. Inside the function, however, you’re working with function parameters and not columns on a row in a table.

     

    This is now a solved issue.  thanks again for reaching out to help!