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
dobregon
Impactful Individual
Impactful Individual

Take text formulas from one column and apply row by row

Hi all,

 

I want to create a calculated column that takes the text of the formula from other column and aplly it and give me te result.

formulas.PNG

 

 

As you can see in the column i have 2 columns of values (value 1 and value 2), then I have the text formula that need to be for each row  (and need to be in text becasue someone in a front end could change the formula of calculation).

What I'm looking for is to create a calculated column that takes the "formula" from each row in the column formula and convert the text to a formula and give me the result of the formula.

Someone can help me?

Thanks in advance, Regards!



Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
1 ACCEPTED SOLUTION
Chihiro
Solution Sage
Solution Sage

I really wouldn't recommend this approach, it is prone to error.

 

If you really must, you'd need to use Expression.Evaluate, combined with Record.Combine in query editor.

Add custom column.

=Expression.Evaluate([formula],Record.Combine({[_=_],#shared}))

0.JPG

 

Have a read of link for the concept used.

https://ssbi-blog.de/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power...

View solution in original post

4 REPLIES 4
Chihiro
Solution Sage
Solution Sage

I really wouldn't recommend this approach, it is prone to error.

 

If you really must, you'd need to use Expression.Evaluate, combined with Record.Combine in query editor.

Add custom column.

=Expression.Evaluate([formula],Record.Combine({[_=_],#shared}))

0.JPG

 

Have a read of link for the concept used.

https://ssbi-blog.de/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power...

dobregon
Impactful Individual
Impactful Individual

Thanks a lot @Chihiro but i'm trying to use the formula and i'm receiving the same error.. I'm sure that i'm doing something wrong or i have something to active in pwoerbi desktop or something.. becasue the query is in DAX and it seems wrong....

evaluate.JPG

Can you help me what i'm doing wrong? 

 

 

Thanks in advance and regards!!

 

 

 



Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

You are applying in DAX. It must be done in query editor using M function.
dobregon
Impactful Individual
Impactful Individual

oh, yes thats work now.  thanks ajajaj it was saturday night.

 

And do you know if i can do queries like Lookupvalue / lookupvalue.. in the column formula and be apllied? Im trying but dont work but it is the solution so so much tank you.



Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

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.