SQL DataFlows

SQL DataFlows

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

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

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In

Best Answers

  • Contributor
    Answer ✓

    Try left(trim(productnumber),1)

  • Coach
    Answer ✓

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

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

Answers

  • Contributor
    Answer ✓

    Try left(trim(productnumber),1)

  • Member

    Perfect this worked thank you

  • Member

    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

  • Coach
    Answer ✓

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

    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?

  • Contributor
    Answer ✓

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

  • Member

    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

  • Contributor

    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

  • Member

    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)

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

    1. 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!**

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In