Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
msksenthil
Helper III
Helper III

M code - Functions: type Function to number

Friends, I try to call one function in to the other kind of nested.

 

M-Code:

let

ADD = (x as any) => let s2 = x+1
in
s2,

SUB = let s33 = ADD -1
in
s33
in
SUB

 

ERROR:

msksenthil_0-1621437641905.png

 

Thanks in advance

 

7 REPLIES 7
msksenthil
Helper III
Helper III

@Greg_Deckler @watkinnc Many thanks both of you. The below code is working fine to me

 

let

ADD = (x as any) => let s2 = x+4
in
s2,

SUB =(x as any) => let s33 = ADD(x) -3
in
s33
in
SUB

Greg_Deckler
Super User
Super User

@msksenthil I would still do it as 2 functions:

 

let
ADD = (x as any) => let s2 = x+1
in
s2
in
ADD



let
SUB = (x as any) => let s33 = ADD(x)-1
in
s33
in
SUB

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
watkinnc
Super User
Super User

You need to complete your ADD function. After you have in s2 , you have to write in ADD. right now, ADD is unevaluated function -1. 


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
Greg_Deckler
Super User
Super User

@msksenthil Perhaps I'm mistaken but don't you want 2 separate functions:

 

let
ADD = (x as any) => let s2 = x+1
in
s2
in
ADD



let
SUB = (x as any) => let s33 = x+1
in
s33
in
SUB

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Nope, I try to use the result of the previous 'let' in the following 'let'

watkinnc
Super User
Super User

Instead of "in s2", try "in s2 in ADD".

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

Sorry, I didn't get you

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors