Forum Discussion

efekrags's avatar
efekrags
Regular Visitor
5 years ago
Solved

convert the str function to a DAX String Function

Need Urgent Help .Please How do I replicate this tableau Formula to a DAX Formula

 

If [Business Unit] = "TMG"
Then
STR(int(Mid([Product Code], Find([Product Code],"-",
FIND([Product Code], "-", 1) + 1) + 1,
(FIND([Product Code], "-",
FIND([Product Code], "-", FIND([Product Code], "-", 1) + 1) + 1))
-
(FIND([Product Code],"-",
FIND([Product Code], "-", 1) + 1) + 1))) * 1)
ELSE
[Product Code]
END.

 

what String function can I use in place of STR in this code?

  • Hi, efekrags 

    STR( ) is a data type conversion function in Tableau, which can convert numeric variables or constants into character variables or constants.

    In powerbi, it's unnecessary to use function to convert data types.You can directly change the Data type of calculated columns in the Column Tool as below:

     

     

    If you don’t like this method of manually changing the data type, you may try the format function.

    Best Regards,
    Community Support Team _ Eason
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

3 Replies

  • efekrags , what are you trying to achieve here

    Something like this

    MID([Product Code], search("-",[Product Code],,0)+1, len([Product Code]))

     

    Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

     

    refer :

    to Split column in power query

    https://www.youtube.com/watch?v=FyO9Vmhcfag

    Power Query - Text.Start, Text.Middle, Text.End

    https://www.youtube.com/watch?v=vky4wPqm0O0

     

    DAX - MId, right, left : https://www.youtube.com/watch?v=-KChpAz_fUo

     

    Search and find : https://www.youtube.com/watch?v=mZt0HJw4gjQ

  • v-easonf-msft's avatar
    v-easonf-msft
    Community Support

    Hi, efekrags 

    STR( ) is a data type conversion function in Tableau, which can convert numeric variables or constants into character variables or constants.

    In powerbi, it's unnecessary to use function to convert data types.You can directly change the Data type of calculated columns in the Column Tool as below:

     

     

    If you don’t like this method of manually changing the data type, you may try the format function.

    Best Regards,
    Community Support Team _ Eason
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      why is this listed as a solution?