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
efekrags
Regular Visitor

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?

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
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:
92.png

 

 

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

91.png

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.

 

View solution in original post

2 REPLIES 2
v-easonf-msft
Community Support
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:
92.png

 

 

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

91.png

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.

 

amitchandak
Super User
Super User

@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

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.