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
Anonymous
Not applicable

Dynamic custom columns from a set of formulas

Hello,

 

I would like to know if this is achievable with power query :

 

Example :

I have a dataset containing 3 columns:

A/B/C

1/4/7

2/5/8

3/6/9

 

I have another dataset containing a set of formulas:

Exemple:

Formula_Id/Formula

D               /A*B+C

C               /A-1

E               /C+D

 

The result of what i want to achieve is adding the columns D/C and E to the first dataset based on the formula associated to each new column the final result would be:

 

A/B/C/D/E

1/4/7/11/0/11

2/5/8/18/1/19

3/6/9/27/2/29

 

Is there a way to dynamically interpret strings as formulas and add it as a custom column?

Thanks.

 

EDIT: Solution : 

 

Data is whatever Data you got, Formulaire contains two columns (variablename/variableformula)

 

let
Source = Data,
Add=List.Accumulate(Table.ToList(Formulaire), Source, (state, current) => Table.AddColumn(state, Text.BeforeDelimiter(current,","), each Expression.Evaluate(Text.AfterDelimiter(current,","), _)))
in
Add

1 ACCEPTED SOLUTION

Hi  @Anonymous ,

 

Thanks for your sharing,could you pls mark your reply as answered to let more people find  it?

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

5 REPLIES 5
edhans
Super User
Super User

What do you mean dynamically interpret strings?

You can merge data from one table into another but you need a key to do that with. Part number, customer number, etc. You could do it based on the rows, but that would only work if all of the column were converted to lists, then reconstructed to a table, and it would require everything be on the same row number - which I usually don't recommend.

Please give us a clear explanation of the desired results and some data we can work with.

 

How to get good help fast. Help us help you.

How To Ask A Technical Question If you Really Want An Answer

How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Here the second dataset doesn't contain data but contains "formulas" (ie "D=A*B+C") a new column D would be created in the first dataset based on these formulas the goal is to easily create/modify new simple columns without opening the power query editor

That is possible, but very very tedious. It would involve the usage of Expression.Evaluate and Expression.Identifier. Perhaps someone will jump in and provide such code, but I am not certian how performant it will be. Unless I am missing something though this would be pretty time consuming to develop and test. More of a consulting thing than a forum answer. 😉



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

I edited the post to offer a possible solution

Hi  @Anonymous ,

 

Thanks for your sharing,could you pls mark your reply as answered to let more people find  it?

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

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