Clay Icon

Extracting Values from String for Proper Structured Outputs

·
·

I’m trying to extract values from a string that looks like this: "doors":80,"total_door_count":200 I want to calculate vacant_units as 5% of total_door_count and return all 3 values cleanly. I tried using a Use AI block with Fields, but I keep getting 0 or missing fields. What’s the best way to extract those and return proper structured outputs?

  • Avatar of Channeled
    Channeled
    APP
    ·
    ·

    To extract the values and calculate vacant_units, you can use an AI formula in Clay. Here's how: 1. Add a new column using the "Ask question about items with AI" option. 2. Choose the formula option. 3. Write a prompt like this: "Extract 'doors' and 'total_door_count' from the input string. Calculate 'vacant_units' as 5% of total_door_count. Return all three values." 4. The AI will generate code to extract and calculate the values. 5. Use the preview feature to check the results. 6. If needed, adjust the prompt or modify the generated code. This approach is more efficient than using a "write to table" block and will save you credits.

  • Avatar of Bo (.
    Bo (.
    ·
    ·

    Alexandrea - Do you mind sending the link (url) to the table so we can take a look?

    (52 kB)
    Image
  • Avatar of Channeled
    Channeled
    APP
    ·
    ·