PricingBlog

Change text color based on calculation (API Data)

  • xioteer-1248372305034350733

    Xioteer

    1 year ago

    Hiho,

    I think I am being a bit of a dummy right now, but can't really figure it out. Maybe need a nudge in the right direction.

    I want to change a style based on a calculation with data coming from an API.

    I have two classes. negative and positive. All that has to change is the color of the text.
    The calculation and conditional are in the screenshot.

    There are also the classes in the style with the respective color changes.

    But nothing happens.

    Tried the Docs with AI, but I seem to miss something here..
    1248372305332011038-image.png
    1248372305634267257-image.png
  • firdaus___-1248373958538035250

    Mr

    1 year ago

    Try use number formula after item. Maybe string not detected amount? Not sure but worth try
  • firdaus___-1248374349761871992

    Mr

    1 year ago

    Or delete if nodes just use greater or equal
  • "If"
  • xioteer-1248377184540823632

    Xioteer

    1 year ago

    ohhh, Yeah I was wondering whether I was actually doing a doubling there.
    probably because I started from the if and then found the greater than.

    New version works great.

    Just the second row in the table is somehow not registering correctly for whatever reason. Everything else works!

    It looks like the IF's output was "true" (string) and the greater than is outputting an actual true boolean value.
    1248377184368984084-image.png
    🎉1
  • Thanks @Mr !
  • max.kayr-1248483294010540092

    Max

    1 year ago

    Hi @Xioteer! The issue here is the variable type. Both inputs are recognized as string. You need to convert them individually to a number with the "Number" node. Then it should work fine 😊
  • xioteer-1248541190643519539

    Xioteer

    1 year ago

    Did that and works as intended! Thanks so much!

    Will keep looking out for the type in the future.
    👍1