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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DanFromMontreal
Helper IV
Helper IV

Custom Function with input

Hello,

I'm trying to create my first fairly custom function but simply cannot make it work.

There is something quiet fondamental that I don't get as a newbie

I want to create a column to my imported dataset, with all rows containing the same value ("A1", "A2", "A3","A?") based on the parameter passed via a custom function.

I go "Add custom function" and typed this function (that doesn't even pass the error check!!!) 

 

   (Account as number)

    let

       if Account = 1 then RowContent = "A1"

       else if Account = 2 then RowContent = "A2"

       else if Account = 3 then RowContent = "A3"

       else RowContent = "A?"

       L0 = RowContent

       in

    L0

 

What I'm doing wrong?

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Try this:

(Account as number) as text => 
let
    L0 = if Account = 1 then "A1"
    else if Account = 2 then "A2"
    else if Account = 3 then "A3"
    else "A?"
in
    L0

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

Try this:

(Account as number) as text => 
let
    L0 = if Account = 1 then "A1"
    else if Account = 2 then "A2"
    else if Account = 3 then "A3"
    else "A?"
in
    L0

Thank you Alexis, it worked like a charm.

There is a long road ahead of me to get proficient but you helped me take my first step.

Regards,

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.