PricingBlog

Getting a third value from a row if first two values match a row in API database

  • deyank-1173535577950400532

    Deyan

    2 years ago

    I am trying to create a formula logic for a form and an output, which checks if two values exist in the same row in columns A and B. If they exist - it returns the value in column C. E.g. can be used for checking status of an order - you enter your order number and post code, and you get order Status as output.

    I created two attributes - order_number and postcode, in which to store the user input. However, I have no idea what formulas to use to check for exact matches for the two variables in any of the rows within the API array. Any help is appreciated!
    1
  • erikbeus-1173541356141039647

    Erik Beuschau

    2 years ago

    It sounds like you want to compare a value from your API call with an attribute in your component? I've shown an example here where I'm using the weather API, and if the index matches my "hour" attribute on my component, then I show "Match" rather than the temperature.
    So you would use the Equals formula - potentially combined with the If formula to apply the correct value.
    Does that make sense? Or did I not understand your issue/question correctly? 😅
    1173541355973251083-Screenshot_2023-11-13_at_09.32.18.png
    ❤️1
  • deyank-1173547715964178482

    Deyan

    2 years ago

    Right, it is similar! Let me provide some more details and examples. First of all, it appears that the structure of the data from the API might be making things difficult. In your weather API, you dynamically get the data for the relevant city. With my google sheet api, I get all the entries in json format and basically when I want to say "get Status", I have to point to a Status in a specific row, e.g. "1" - which makes it static.
    1173547715590889535-image.png
    1173547715796418600-image.png
  • Tod-1173547718153621538

    Tod

    2 years ago

    Great energy @Deyan! Your continuous contribution to the toddle Community just made you advance to Community Level 1!
  • deyank-1173548216021696512

    Deyan

    2 years ago

    The idea is to work like this - you enter an order ID and a postcode, and if those two match exactly the contents of a row in the database, it should output the relevant "status" value from that same row.
    1173548215853920277-image.png
  • alternatively, if you enter Order ID 1001 but postcode 2005, it should return "No result", since those two values match no row
  • deyank-1173548839597260841

    Deyan

    2 years ago

    P.S. I think this little form can have application for various companies, Microsoft power apps focus a great deal on such solutions
  • erikbeus-1173551430171369495

    Erik Beuschau

    2 years ago

    Ah I see. In that case, I think you're looking for the Find formula that allows you to search through an array of elements to find a match. In your case, you would then match your values against the order number + postcode columns to see if there's a match. And if you find a match, you would then display the status.
    I'm not quite sure about your data structure, but in this screenshot is an example of how you might achieve it
    1173551429764534292-Screenshot_2023-11-13_at_10.13.11.png
  • Thanks for the effort, I really appreciate it! This is the API I am using
  • deyank-1173552849762910258

    Deyan

    2 years ago

    I see the logic in your formula, but I am not sure how the API data can be applied to it, such that to make the array dynamically get the API data any time the formula runs
  • erikbeus-1173593900808683590

    Erik Beuschau

    2 years ago

    Your API seems to return an array of objects. If you paste your url into a toddle API, it should fetch the data automatically and let you work with each column separately in formulas.
    I'm not quite sure I understand your specific issue. Perhaps you could share a video and/or invite me to your project so I can help you out? erik@toddle.dev
    1173593900229861476-Screenshot_2023-11-13_at_13.01.12.png
    1173593900544430180-Screenshot_2023-11-13_at_13.01.38.png
  • deyank-1173595982617923655

    Deyan

    2 years ago

    I invited you! The url of the project is https://testbank-web_elements.toddle.site/
  • erikbeus-1173601651043606558

    Erik Beuschau

    2 years ago

    I sent you a DM for details 👍
  • deyank-1173613199808004126

    Deyan

    2 years ago

    @Erik Beuschau created a new formula logic and it works just perfectly. I also tried adding new rows in the Google sheet and it worked right away with those too. I am super happy with the solution!
    1173613199581528134-image.png
    🙌3
  • deyank-1173613587101667338

    Deyan

    2 years ago

    This basically can allow for all sort of status checks for product deliveries, support thread status, insurance claims status, etc. I am writing this so that future toddlers can find this thread and make use of the amazing flow that Erik made.
  • erikbeus-1173614654388453526

    Erik Beuschau

    2 years ago

    I'm glad it was helpful 🙂
  • Tod-1173614655965515867

    Tod

    2 years ago

    Great energy @Erik Beuschau! Your continuous contribution to the toddle Community just made you advance to Community Level 11!