Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

DAX Measure Error on Search Function

Hi Experts

 

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

 

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

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    thanks, getting a 0 - surely this should be 1 

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

2 Replies

  • ppm1's avatar
    ppm1
    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

    • Anonymous's avatar
      Anonymous
      Not applicable

      thanks, getting a 0 - surely this should be 1 

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