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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Pass Parameter as column name in custom column calculation

Example Table:

OriginDestinationScenario 1Scenario 2Scenario 3
AB101112
BC63

2

 

Thank you in advance for helping me solve this problem! 

 

I have 2 parameters that define which 2 fields I want to use in a calculated new column. For example: A user selects Scenario 2 and Scenario 3 as Parameter 1 and Parameter 2, respectively. In a new calculated column I would see the results of Scenario 2 value - Scenario 3 value, as shown in the Calc Col below. What does the syntax look like to create this calculated column based on the user selected parameters?

 

OriginDestinationScenario 1Scenario 2Scenario 3Calc Col
AB101112-1
BC6321
2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

u could, peraphs use this sheme:

 

a function like this:

 

let
    newTab = (Col1,Col2)=>Table.AddColumn(Table, "newColumnName", each Record.Field(_, Col1)-Record.Field(_, Col2))

in
    newTab

 

which when invoked using the names of two columns of you table:

 

image.png

gives:

 

image.png

 

 

View solution in original post

Anonymous
Not applicable

I think i figured it out. I modified your Function to be a simple addcolumn step:

 

Table.AddColumn(PreviousStep, "Delta", each Record.Field(_, #"Scenario 1")-Record.Field(_, #"Scenario 2"))

 

Where Scenario 1 and Scenario 2 are the query parameter names. Seems to work! 

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

u could, peraphs use this sheme:

 

a function like this:

 

let
    newTab = (Col1,Col2)=>Table.AddColumn(Table, "newColumnName", each Record.Field(_, Col1)-Record.Field(_, Col2))

in
    newTab

 

which when invoked using the names of two columns of you table:

 

image.png

gives:

 

image.png

 

 

Anonymous
Not applicable

I think i figured it out. I modified your Function to be a simple addcolumn step:

 

Table.AddColumn(PreviousStep, "Delta", each Record.Field(_, #"Scenario 1")-Record.Field(_, #"Scenario 2"))

 

Where Scenario 1 and Scenario 2 are the query parameter names. Seems to work! 

 

 

Anonymous
Not applicable

Close! The only issue I am running into is the parameters are query parameters so I am not sure how to assign the query parameters to your function parameters? If that makes sense?

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors