How to get the first character of a string in domo beast mode analyzer

Options

Hi I am trying to get the first letter in the product number field.

I have created a test field to remove any extra white spaces the product number field would come with and here is the calculation:

TRIM(ProductNumber)

Next I am trying to use the Left function to get the first letter from that test field without any extra white spaces this field is called prod art:

LEFT(Test,-9)

Here are the results I am getting

Best Answers

  • jessdoe
    jessdoe Contributor
    Answer ✓
    Options

    Try left(trim(productnumber),1)

  • GrantSmith
    GrantSmith Coach
    Answer ✓
    Options

    CASE WHEN Prod Art = 'A' THEN 'Artwork'
    WHEN Prod Source = 'M' THEN 'Sourcing'
    ELSE 'No'
    END
    
    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • jessdoe
    jessdoe Contributor
    Answer ✓
    Options

    You need tick marks around column names that contain spaces. Prod Art and Prod Source should have ` before and after them.

Answers

  • jessdoe
    jessdoe Contributor
    Answer ✓
    Options

    Try left(trim(productnumber),1)

  • Utz
    Utz Member
    Options

    Perfect this worked thank you

  • Utz
    Utz Member
    Options

    Had one more question regarding this topic I am not sure if there is a OR operator in domo beast mode but I am trying to make a formula where if "prod art" is "A" then display "Artwork" else if when "Prod Source" is "M" then "Sourcing" Else "No"

    Here is the formula i have created which is giving me a syntax error:

    CASE WHEN Prod Art ('A') THEN 'Artwork' ELSE WHEN Prod Source ('M') THEN 'Sourcing' ELSE 'No' END

  • Utz
    Utz Member
    Options
  • GrantSmith
    GrantSmith Coach
    Answer ✓
    Options

    CASE WHEN Prod Art = 'A' THEN 'Artwork'
    WHEN Prod Source = 'M' THEN 'Sourcing'
    ELSE 'No'
    END
    
    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Utz
    Utz Member
    Options

    Hi Grant,

    Thank you for the quick response seems like there is a syntax error with the code do you know what it could be?

  • jessdoe
    jessdoe Contributor
    Answer ✓
    Options

    You need tick marks around column names that contain spaces. Prod Art and Prod Source should have ` before and after them.

  • Utz
    Utz Member
    Options

    Hey @jessdoe @GrantSmith thank you so much for the previous formula so I am running into an issue with it. So it seems like the first condition is coming correctly if Prod Art = A then I am getting artwork but when the second condition comes into effect it doesn't give me sourcing when the 3rd character in product number = M take a look at the screenshot:

    Here are the formulas:

    Prod Sourcing = left(trim(productnumber),3)

    Exclusive= CASE WHEN Prod Art = 'A' THEN 'Artwork'
    WHEN Prod Source = 'M' THEN 'Sourcing'
    ELSE 'No'
    END

  • jessdoe
    jessdoe Contributor
    Options

    Ok wait @Utz I'm lost. Where is Prod Source coming in? I don't even see that column in your original screenshot. Based on your original question, the case statement should read

    case left(trim(productnumber),3)
    when 'A' then 'Artwork'

    when 'M' then 'Sourcing'

    else 'No' end


    or, if you already have the beastmode for Prod Art created then you should be able to use:

    case

    when Prod Art = 'A' then 'Artwork'

    when Prod Art = 'M' then 'Sourcing'

    else 'No'

    end

  • Utz
    Utz Member
    Options

    Hi @jessdoe Sorry I think the issue is with prod sourcing I included the column in this screen shot but the formula is giving me the first 3 characters when i only need the third character of the string. Here is the screen shot:

    The formula that is giving me the first 3 letters which is only supposed to give only the third character which is "M"

    Prod Sourcing = left(trim(productnumber),3)

  • GrantSmith
    Options

    If you want just the third character, you can use substring:

    SUBSTRING(`productnumber`, 3, 1)
    

    3 = starting character number (1-based)

    1 = number of characters to extract

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**