Forum Discussion

LukaszKoper's avatar
LukaszKoper
Regular Visitor
6 years ago
Solved

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

5 Replies

  • camargos88's avatar
    camargos88
    Icon for Community Champion rankCommunity Champion

    Hi LukaszKoper ,

     

    Try this one for a custom column:

    Expression.Evaluate(Text.Replace([Column1], """", ""))

     

    • LukaszKoper's avatar
      LukaszKoper
      Regular 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?

       

      • LukaszKoper's avatar
        LukaszKoper
        Regular 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],"""",""))

         


         
         
         
         
         
         
  • v-diye-msft's avatar
    v-diye-msft
    Icon for Community Support rankCommunity 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!