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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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 IV
Resolver IV

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 IV
Resolver IV

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors