Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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

3 REPLIES 3
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.

 

why is this listed as a solution?

 

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors