Forum Discussion
custom function creates but expression error when add column/invoke custom function getting
- 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!
HI mcraven1845,
According to your discretion, it seems like you need to calculate result based on current column value. It possible to get current column label as parameter to calculate in dax formula.
Can you lease share a pbix file with same data structure fake data so that I can test to coding formula on it?
Regards,
Xiaoxin Sheng
I would love to share it but I'm not sure exactly what the pbix file is or how to share it here?
- Anonymous7 years agoNot applicable
HI mcraven1845,
You can upload to onedrive or google drive and share link here. If your data are from external datasource, you can copy part of your records to excel sheet and pack it with your pbix file for share.
Regards,
Xiaoxin Sheng
- mcraven18457 years agoFrequent Visitor
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!