0

To colour with conditional style with the id ?

Hi,

Is there a way to color sommes values in a column with the conditional style with the id ?

Normally one use the same letters of some names to color them.

IE :

words beginning with "ab"

Words finishing with "ness"

But if one wants to color some names which have no commun letters, would it be possible to use a formula with the id numbers of this values ?

IE

ID 346, ID 234, ID 123.

If yes, could someone tell me the way to do it ?

 

Thank you.

29 replies

null
    • Riccardo.1
    • 3 yrs ago
    • Reported - view

    How do you define those ID's? What is the relation between the ID's and the letters? As you write "no common letters" do you mean to "ab" and "ness"? If so you can try the same code you already have with "not contain". 

    If you want to color fields by record ID this could be a possible code for you:

    let myARR := [346, 234, 123];
    let myNR := number(Nr);
    let myCheck := for i in myARR do
    if contains("#" + myNR + "#", "#" + i + "#") then
    i
    end
    end;
    if cnt(myCheck) > 0 then
    styled(text(myCheck), "green", "", "check")
    else
    styled(text(myCheck), "red", "", "x")
    end

    I'm not sure if that is what you really need. Maybe you can elaborate further on your problem.

    • Addinsell
    • 3 yrs ago
    • Reported - view

    Hi Riccardo,

    I tried your formula but I get this error :

     "A column has not been found Nr on the line 1, column 50"

     

    C878F933-F48A-4584-B97F-6E236DBF3C34

    • Riccardo.1
    • 3 yrs ago
    • Reported - view

    Try:

    let myNr:= number(_id)

    instead of

    let myNr:= number(Nr)

    • Addinsell
    • 3 yrs ago
    • Reported - view

    Thanks a lot Riccardo

     

    Ok, no more error now but nothing happens !

    No colored name in front of the ID…

    Should the formula be in the "conditional style" formula  in the filter box up in the column of the names ?

    • Riccardo.1
    • 3 yrs ago
    • Reported - view

    you can do it with conditional style, but then you have to modify the the code a little bit. You need two rules (règles):

    1st rule

    ----------

    let myARR := [3, 10, 16];
    let myNR := number(_id);
    let myCheck := for i in myARR do
    if contains("#" + myNR + "#", "#" + i + "#") then
    i
    end
    end;
    cnt(myCheck) > 0

    ----------

    2nd rule

    let myARR := [3, 10, 16];
    let myNR := number(_id);
    let myCheck := for i in myARR do
    if contains("#" + myNR + "#", "#" + i + "#") then
    i
    end
    end;
    cnt(myCheck) = 0

    -----------

    And then of course set a color for each of the rules.

    • Addinsell
    • 3 yrs ago
    • Reported - view

    Thanks Riccardo.

    Why two rules ? 

    Does that mean two formulas following in the same one ?

    Or two differents formulas and if yes, how does that work ?

    • Addinsell
    • 3 yrs ago
    • Reported - view

    Maybe you speak about the "conditional style" rules ?

    • Addinsell
    • 3 yrs ago
    • Reported - view

    It must be that but 

    I get the same error on the two :

     "Expected end : styled on the line 9, column 6 on the second rule"

    AC770D8B-0DDE-4DFF-86B3-CC7EB7C57E7B

    • Addinsell
    • 3 yrs ago
    • Reported - view

    By the way why in the two rules there is two colors each time (red and green) ?

    • Riccardo.1
    • 3 yrs ago
    • Reported - view

    We had a missunderstanding. Forget the first code I sent. There are different ways to color a field. And as you used style conditional before I think it's best you use it for this as well. 

    For that you need just the two codes I sent today. 

    Set a first rule: Operateur: f(x) Formule:

    ----------

    let myARR := [3, 10, 16];
    let myNR := number(_id);
    let myCheck := for i in myARR do
    if contains("#" + myNR + "#", "#" + i + "#") then
    i
    end
    end;
    cnt(myCheck) > 0

    ----------

    -> This code will color all the fields that have a match with your ID - Array.

    Add another rule: Operateur: f(x) Formule:

    ----------

    2nd rule

    let myARR := [3, 10, 16];
    let myNR := number(_id);
    let myCheck := for i in myARR do
    if contains("#" + myNR + "#", "#" + i + "#") then
    i
    end
    end;
    cnt(myCheck) = 0

    -> This code will call the fields that are not in your arrray. 

    -----------

    Then where it says "Cell" you can chose on a color manually. With this approach you DO NOT need any "styled("","green","","")" and so on, because you decide in style conditionel on the color.

    • Addinsell
    • 3 yrs ago
    • Reported - view

    Thanks Riccado.

    I get the same error on the both functions :

    "The function is not defined nombfe (nid) on the line 2, column 25"

    (By the way why "nid" and not "id" ?)1FF496B5-1649-4168-B2DA-AE2EE8000F3E

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    Try number(_id)

    Translation to french of ninox code (functions) doesn't work.

    Steven

    • Addinsell
    • 3 yrs ago
    • Reported - view

    Thanks a lot Steven, you are right : it works now !

    • Addinsell
    • 3 yrs ago
    • Reported - view

    Incidentaly about the ID do you know a way to remove records with the same kind of way ? I mean with a formula.

     

    I have a lot of records to remove from a table.

     

    I am on an Ipad and I and there is no yet possiblity to right click on the rows like on the Mac.

     

    The ID to remove are :

    First one : ID 3825

    Last one : ID 4249

    So from ID 3825 to  ID 4249

     

    In the notice there is a "delete" formula, it should be possible but I don't know how to manage it.

     

    Thank you

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    Becarefull to use this, better make a backup first before trying this out:

    for i in range(3825, 4349) do delete(i) end

    Steven

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    Sorry, it should be:

    for i in range(3825,4349) do delete(record('Votre nom de table',i)) end

    Steven

    • Addinsell
    • 3 yrs ago
    • Reported - view

    Thanks Steven.

    How does the script understand that (3825,4349) means from 3825 to 4349 and not 3825 and 4349 ?

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    The command 'for i in range(start,stop) do' is a kind of loop is and it goes over all the numbers in this range.
    Then each time it takes a record from your table with the current number as id and deletes it. Then he adds 1 internally and repeats this loop until he has the end number.

    • Addinsell
    • 3 yrs ago
    • Reported - view

    I tried your function but I get :

    "this formula can't modify datas"

    • Addinsell
    • 3 yrs ago
    • Reported - view

    6FC70B31-A0F3-46C2-8FBB-EA767666F86D

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    You can use this code in a button or in the console

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    Et ensuite, vous pouvez retirer le bouton.

    • Addinsell
    • 3 yrs ago
    • Reported - view

    Thanks Steven.

    Why some formulas work with a button and others don't ?

    • Addinsell
    • 3 yrs ago
    • Reported - view

    Thanks.

     

    Strange : only the 450 has been deleted…

     

    (By the way is it possible to go back after having push on a button ?)

    F0A9981D-7049-4DA8-8A69-4A41C2484E44

    • Addinsell
    • 3 yrs ago
    • Reported - view

    Sorry, I made a big mistake…

    I thought only 450 and 737 will be deleted but it is from 450 to 737 so it works but what should I change if I wanted to delete only this two ones ?

Content aside

  • 3 yrs agoLast active
  • 29Replies
  • 1457Views