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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! 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
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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