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
abujouz86
Helper II
Helper II

Remove characters convert text to numbers

I have a column of data that includes for example "1 person" or "10/1". I want to remove the characters leaving only the number and if there is a / I want to add the number to the left to the number to the right (e.g. 10/1 = 11).

 

In excel I would write the formula this way:

=IF(ProdRouteTrans[CATEGORYID]="","",
VALUE(TRIM(IF(ISERROR(FIND("/",ProdRouteTrans[CATEGORYID])),
LEFT(ProdRouteTrans[CATEGORYID],2),
LEFT(ProdRouteTrans[CATEGORYID],
FIND("/",ProdRouteTrans[CATEGORYID])-1))))
+ IF(ProdRouteTrans[CATEGORYID]="","",
VALUE(TRIM(IF(ISERROR(FIND("/",ProdRouteTrans[CATEGORYID])),0,MID(ProdRouteTrans[CATEGORYID],
FIND("/",ProdRouteTrans[CATEGORYID])+1,2))))))
 
But when I write the dax in pbi I get an error message "Expressions that yield variant data-type cannot be used to define calculated columns." Can someone help me fix this formula? Thank you!
12 REPLIES 12

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.