Forum Discussion
Changing text to formula
Hello,
With substring function i changed text from "6x40HQ,1x20" to "6*76+1*33". Now I would like to execute this "6*76+1*33" as a formula.
Best Regards,
Lukasz Koper
Hi LukaszKoper ,
Try this one for a custom column:
Expression.Evaluate(Text.Replace([Column1], """", ""))
5 Replies
- camargos88
Community Champion
Hi LukaszKoper ,
Try this one for a custom column:
Expression.Evaluate(Text.Replace([Column1], """", ""))
- LukaszKoperRegular Visitor
To elaborate I have a column (container-typ) imported from excel that has values like:
20
40
40HQ
40HC
4x40HQ,1x20
Those are types of containers and f.e container type 20 has volume of 33 m^3, 40HQ has volume of 76m^3
In DAX I use this querry
SUBSTITUTE (SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE( SUBSTITUTE ([Container-typ], "x", "*"),"20", 33),"40HQ",76),"40HC",76),"40",67),",","+"),"LCL",""),"DDP","")
to change container type to the volume it has and change expresions like 4x40HQ,1x20 to somethig that looks like formula 4*76+1*33.
In Custom Column I would have to use powerquerry-m. My question is how to change DAX querry to powerquerry-m to get the same effect and how to then run it like a formula?
- LukaszKoperRegular Visitor
Ok got it Thank You camargos88 !
I used custom columns, first with this querry=Text.Replace (Text.Replace(Text.Replace(Text.Replace(Text.Replace(Text.Replace(Text.Replace( Text.Replace ([#"Container#(lf)-typ"], "x", "*"),"20", "33"),"40HQ","76"),"40HC","76"),"40","67"),",","+"),"LCL",""),"DDP","")
then this querry=Expression.Evaluate(Text.Replace([Volume],"""",""))
- amitchandak
Super User
LukaszKoper , refer if this can help
https://docs.microsoft.com/en-us/powerquery-m/expression-evaluate
- v-diye-msft
Community Support
Hi LukaszKoper
if the above posts help, please kindly mark it as a solution to help others find it more quickly. If not, please kindly elaborate more. thanks!