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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
lisawinck
Regular Visitor

An argument of the MID has the wrong data type or has an invalid data value

I am getting the above error when trying to combine the MID function with the SEARCH function. Training Type = trim(MID(Competency[Survey Question],iferror(SEARCH(":",Competency[Survey Question],,0),0),iferror(SEARCH("-",Competency[Survey Question],,0),0))) The search functions work fine when using them alone without the MID function. SEARCH(":",Competency[Survey Question],,0) SEARCH("-",Competency[Survey Question],,0) When I try to use them as start and stop I get the error. If I replace the first search with a numerical number, it runs without error. Does anyone know if this is a known issue or have any suggestions? Thanks!

1 ACCEPTED SOLUTION
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @lisawinck,

 

If a Competency[Survey Question] doesn't have a ":", the second parameter of "MID" will be 0, which is illegal. I would suggest making some changes of the formula.

 

Training Type = 
TRIM (
    MID (
        Competency[Survey Question],
        IFERROR ( SEARCH ( ":", Competency[Survey Question],, 1 ), 1 ),
        IFERROR ( SEARCH ( "-", Competency[Survey Question],, 0 ), 0 )
    )
)

An argument of the MID has the wrong data type or has an invalid data value.JPG

 

 

 

 

 

 

 

 

 

 

BTW, it would be a good idea to format the formula with: http://www.daxformatter.com/

 

Best Regards!

Dale

Community Support Team _ Dale
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-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @lisawinck,

 

If a Competency[Survey Question] doesn't have a ":", the second parameter of "MID" will be 0, which is illegal. I would suggest making some changes of the formula.

 

Training Type = 
TRIM (
    MID (
        Competency[Survey Question],
        IFERROR ( SEARCH ( ":", Competency[Survey Question],, 1 ), 1 ),
        IFERROR ( SEARCH ( "-", Competency[Survey Question],, 0 ), 0 )
    )
)

An argument of the MID has the wrong data type or has an invalid data value.JPG

 

 

 

 

 

 

 

 

 

 

BTW, it would be a good idea to format the formula with: http://www.daxformatter.com/

 

Best Regards!

Dale

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

Also, that's a cool tool.  Thanks!

That worked perfectly!  Thank you!!  I thought the zero was the correct method.  Thanks for your help!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors