[FONT="]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="] [/FONT]
[FONT="]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="] [/FONT]
[FONT="]I'm new to this M language but I have had experience in programming. Your help is appreciated![/FONT]
[FONT="] [/FONT]
[FONT="]Here is the complex function[/FONT]
[FONT="] [/FONT]
[FONT="]let FYR1 = (CYR,UpgradeRpDate,CurrentMaint,UpgradeCost) => if CYR([UpgradeRpDate])="TRUE" then [CurrentMaint]+[UpgradeCost] else [CurrentMaint]
in FYR1
[/FONT]
[FONT="]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="] [/FONT]
[FONT="] Current Yr Next year --------------------Fiscal Yr Cost----------------------------[/FONT]
[FONT="]Type Maint cost Maint cost 2019 2020 2021 2022 2023 update date upgrade cost[/FONT]
[FONT="]software 1,000 1,100 1,000 1,100 1,760 1,331 1,464 7/1/2021 550[/FONT]
[FONT="] [/FONT]
[FONT="]to calculate cost for each fiscal year the formulas are below[/FONT]
[FONT="] [/FONT]
[FONT="] IF(YEAR(NOW())=[],[Current Year Maintenance]+[Upgrade/Replace Cost],[Current Year Maintenance])[/FONT]
[FONT="] [/FONT]
[FONT="]IFERROR(next yr maint cost/ current yr maint cost,0)[/FONT]
[FONT="] [/FONT]
[FONT="]2019 Fiscal Yr Cost à IF(YEAR(NOW())=YEAR(update date),current yr maint cost+upgrade cost,current yr maint cost)[/FONT]
[FONT="]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="])+ upgrade cost, current yr maint cost * IFERROR(next yr maint cost/ current yr maint cost,0))[/FONT]
[FONT="]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="]…
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="]
[/FONT]
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="] [/FONT]
[FONT="]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="] [/FONT]
[FONT="]I'm new to this M language but I have had experience in programming. Your help is appreciated![/FONT]
[FONT="] [/FONT]
[FONT="]Here is the complex function[/FONT]
[FONT="] [/FONT]
[FONT="]let FYR1 = (CYR,UpgradeRpDate,CurrentMaint,UpgradeCost) => if CYR([UpgradeRpDate])="TRUE" then [CurrentMaint]+[UpgradeCost] else [CurrentMaint]
in FYR1
[/FONT]
[FONT="]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="] [/FONT]
[FONT="] Current Yr Next year --------------------Fiscal Yr Cost----------------------------[/FONT]
[FONT="]Type Maint cost Maint cost 2019 2020 2021 2022 2023 update date upgrade cost[/FONT]
[FONT="]software 1,000 1,100 1,000 1,100 1,760 1,331 1,464 7/1/2021 550[/FONT]
[FONT="] [/FONT]
[FONT="]to calculate cost for each fiscal year the formulas are below[/FONT]
[FONT="] [/FONT]
[FONT="] IF(YEAR(NOW())=[],[Current Year Maintenance]+[Upgrade/Replace Cost],[Current Year Maintenance])[/FONT]
[FONT="] [/FONT]
[FONT="]IFERROR(next yr maint cost/ current yr maint cost,0)[/FONT]
[FONT="] [/FONT]
[FONT="]2019 Fiscal Yr Cost à IF(YEAR(NOW())=YEAR(update date),current yr maint cost+upgrade cost,current yr maint cost)[/FONT]
[FONT="]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="])+ upgrade cost, current yr maint cost * IFERROR(next yr maint cost/ current yr maint cost,0))[/FONT]
[FONT="]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="]…
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="]
[/FONT]