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

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

Reply
Anonymous
Not applicable

DAX Measure Error on Search Function

Hi Experts

 

I cannot see my error on the SEARCH VAR in the following 
Error Message

BlueWhite111_0-1681819910303.png

 

Measure = 
VAR _USERPRINCIPALNAME = CONCATENATE(SELECTEDVALUE(pg_control_cases[country_dim.country_name]),SELECTEDVALUE(pg_control_cases[store_name]))

VAR SeparatorPosition = SEARCH(",",_USERPRINCIPALNAME)

VAR _Country = LEFT(_USERPRINCIPALNAME, SeparatorPosition - 1)
VAR _Store = RIGHT(_USERPRINCIPALNAME, SeparatorPosition + 1)

RETURN
SeparatorPosition

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

thanks, getting a 0 - surely this should be 1 

VAR SeparatorPosition = SEARCH(",",_USERPRINCIPALNAME,1,0)

View solution in original post

2 REPLIES 2
ppm1
Solution Sage
Solution Sage

You can provide values for the 3rd and 4th terms in the SEARCH function to avoid that. The 4th is the not found value. Usually people put 1 for the start position and 0 for not found.

 

Pat

Microsoft Employee
Anonymous
Not applicable

thanks, getting a 0 - surely this should be 1 

VAR SeparatorPosition = SEARCH(",",_USERPRINCIPALNAME,1,0)

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!

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.