Expression error when add column/invoke custom function...can't convert the value

cravenmc

New Member
Joined
Jan 15, 2015
Messages
2
[FONT=&quot]I successfully created a workbook that had a combined sheet (that contained 7 other workbooks) that successfully used several formulas/functions to get 5 Fiscal Years totals and then produced slicers. I wanted a way to allow the 7 managers to update their individual workbooks an then automate the combining of the data with the added formulas/functions. I am new to data model and power bi but I've made great progress until I try to add a column using the successfully created custom function. I will get to the stuff in the power bi first and at the bottom of this post I'll show what I have working in just excel without the automation of the combined files.

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 successfully but when I try to add column, invoke custom function it gives me [/FONT]

[FONT=&quot] [/FONT]
[FONT=&quot]An error occurred in the ‘FYR1’ query. Expression.Error: We cannot convert the value #date(2019, 7, 1) to type Function.
Details:
Value=7/1/2019
Type=Type[/FONT]

[FONT=&quot] [/FONT]
[FONT=&quot]I'm new to this M language but I have had experience in programming. Your help is appreciated![/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Here is the complex function[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]let FYR1 = (CYR,UpgradeRpDate,CurrentMaint,UpgradeCost) => if CYR([UpgradeRpDate])="TRUE" then [CurrentMaint]+[UpgradeCost] else [CurrentMaint]
in FYR1

[/FONT]

[FONT=&quot]worksheet to take the provided current year maintenance cost of equipment along with the next year maintenance cost to produce the projected cost for the next five years. I used 4 of the 10 provided columns (2,3,9,10) below. Here is a simple example to follow:[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Current Yr Next year --------------------Fiscal Yr Cost----------------------------[/FONT]
[FONT=&quot]Type Maint cost Maint cost 2019 2020 2021 2022 2023 update date upgrade cost[/FONT]
[FONT=&quot]software 1,000 1,100 1,000 1,100 1,760 1,331 1,464 7/1/2021 550[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]to calculate cost for each fiscal year the formulas are below[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] IF(YEAR(NOW())=[],[Current Year Maintenance]+[Upgrade/Replace Cost],[Current Year Maintenance])[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]IFERROR(next yr maint cost/ current yr maint cost,0)[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]2019 Fiscal Yr Cost à IF(YEAR(NOW())=YEAR(update date),current yr maint cost+upgrade cost,current yr maint cost)[/FONT]
[FONT=&quot]2020 Fiscal Yr Cost -> IF(YEAR(NOW())+1=YEAR(update date),( current yr maint cost * IFERROR(next yr maint cost/ current yr maint cost,0)[/FONT]
[FONT=&quot])+ upgrade cost, current yr maint cost * IFERROR(next yr maint cost/ current yr maint cost,0))[/FONT]
[FONT=&quot]2021 Fiscal Yr Cost -> IF(YEAR(NOW())+2=YEAR(update date),( current yr maint cost * IFERROR(next yr maint cost/ current yr maint cost,0)^2)+ upgrade cost, current yr maint cost * IFERROR(next yr maint cost/ current yr maint cost,0)^2)[/FONT]
[FONT=&quot]…

I'm having a hard time duplicating this formula as a function that works in power BI. Like I said earlier I was finally able to create the custom function successfully but when I try to add it to the data model I get the error.

I sure hope one of you guru's will take the time to help me. I so appreciate it! thanks in advance![/FONT]

[FONT=&quot]
[/FONT]
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top