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
Anonymous
Not applicable

How to use MID with -1 to get exactly character section

 

Below code is working fine to get any values before "."

 

Column = MID('STC2019_T csv'[SAM],1,FIND(".",'STC2019_T csv'[SAM],1,0))
Result :
 
1.jpgBut when I add "-1" in order to avoid showing "." I got error :
 
Column = MID('STC2019_T csv'[SAM],1,(FIND(".",'STC2019_T csv'[SAM],1,0)-1))
Result :
2.jpg
 
 
any advice
 
1 ACCEPTED SOLUTION
PANDAmonium
Resolver III
Resolver III

Your FIND function is returning 0 if not found so the -1 turns the "Number of Characters" part in your MID equation to a negative number which cannot be accepted there since it can't retreive a negative amount of characters.

 

So...I haven't fully thought it through, but I'm fairly sure you can just change your not found value to one and you should be good.

 

Column = MID('STC2019_T csv'[SAM],1,(FIND(".",'STC2019_T csv'[SAM],1,1)-1))

View solution in original post

2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

I think there are integers in the column "SAM". As PANDAmonium said, it occurs the problem due to your find function returns 0. You need to set the number bigger,like 100. Then the integers will be displayed entirely.

Column = MID('STC2019_T csv'[SAM],1,(FIND(".",'STC2019_T csv'[SAM],1,100)-1))

5.PNG

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
PANDAmonium
Resolver III
Resolver III

Your FIND function is returning 0 if not found so the -1 turns the "Number of Characters" part in your MID equation to a negative number which cannot be accepted there since it can't retreive a negative amount of characters.

 

So...I haven't fully thought it through, but I'm fairly sure you can just change your not found value to one and you should be good.

 

Column = MID('STC2019_T csv'[SAM],1,(FIND(".",'STC2019_T csv'[SAM],1,1)-1))

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.