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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
smpa01
Community Champion
Community Champion

Ensuring typesafe

how can I ensure, the function execution result returns same type as mentioned in the function?

 

let
    test_type = () as text=> "Hello",
    tbl = #table(type table [Name = text, Score = number], {{"Betty", 90.3}, {"Carl", 89.5}}),
    #"Added Custom" = Table.AddColumn(tbl, "Custom", each test_type())
    /*want to avoid doing below and the type needs to cascade from the function*/
    /*Table.AddColumn(tbl, "Custom", each test_type(), type text)*/
in
    #"Added Custom"

 

getting this

smpa01_0-1746036387709.png

desire this

smpa01_1-1746036490107.png

without requiring to do this

Table.AddColumn(tbl, "Custom", each test_type(), type text)

 @AlexisOlson @ImkeF 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

How about this?

= Table.AddColumn(tbl, "Custom", each test_type(), Value.Type(test_type()))

View solution in original post

3 REPLIES 3
AlexisOlson
Super User
Super User

How about this?

= Table.AddColumn(tbl, "Custom", each test_type(), Value.Type(test_type()))

Smashing

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Why not first define the records, then build your #table by referring to the records and the the function, and assign the text type in the #table function itself?

 

--Nate

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.