Forum Discussion

Karthikgayathri's avatar
3 years ago

undefined

rubayatyasmin 

 i need output as text without the bracket  ex : Head Office 

 I used to write the code 

Right ( dim( customer) , search("(" , dim( customer) 1, len ( dim( customer )+1)-1)

 My output is (Head Office)

 I need without bracket in dax query 

 

 

 

20 Replies

  • rubayatyasmin's avatar
    rubayatyasmin
    Community Champion

    Use MID func. 

     

    =MID([ColumnName], FIND("(", [ColumnName], 1, LEN([ColumnName]), 0) + 1,
    FIND(")", [ColumnName], 1, LEN([ColumnName]), 0) - FIND("(", [ColumnName], 1, LEN([ColumnName]), 0) - 1)

     

    replace col name with actual column name . 

     

    • Karthikgayathri's avatar
      Karthikgayathri
      Helper I

      Instead of 0 only u used len function then again using 0 how u used 0 ?

      • rubayatyasmin's avatar
        rubayatyasmin
        Community Champion

        Here is the explanation of the formula:

        • FIND("(", [ColumnName], 1, LEN([ColumnName]), 0) + 1 - It finds the first character after the opening bracket.
        • FIND(")", [ColumnName], 1, LEN([ColumnName]), 0) - FIND("(", [ColumnName], 1, LEN([ColumnName]), 0) - 1 - It calculates the number of characters to extract.
        • MID([ColumnName], ..., ...) - This function will then extract the required number of characters starting from the specified position.

        Also, know the details of the Find function. 

         

         

        refer: https://learn.microsoft.com/en-us/dax/find-function-dax

         

         

  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi Karthikgayathri 
    Please try

    Bill to Customer 2 =
    SUBSTITUTE ( SUBSTITUTE ( dimCustomer[Bill to Customer], ")", "" ), "(", "" )
    • Karthikgayathri's avatar
      Karthikgayathri
      Helper I

       

       for your query above image 

      output . I need only head office without bracket 

      • tamerj1's avatar
        tamerj1
        Community Champion

        Karthikgayathri 
        Sorry. I misunderstood the requirement. Please try 

        Bill to Customer 2 = 
        VAR String = dimCustomer[Bill to Customer]
        VAR Items = SUBSTITUTE ( SUBSTITUTE ( String, "(", "|" ), ")", "|" )
        RETURN
            PATHITEM ( Items, 2 )