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
-
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")
endI'm not sure if that is what you really need. Maybe you can elaborate further on your problem.
-
Hi Riccardo,
I tried your formula but I get this error :
"A column has not been found Nr on the line 1, column 50"
-
Try:
let myNr:= number(_id)
instead of
let myNr:= number(Nr)
-
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 ?
-
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.
-
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 ?
-
Maybe you speak about the "conditional style" rules ?
-
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"
-
By the way why in the two rules there is two colors each time (red and green) ?
-
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.
-
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" ?)
-
Try number(_id)
Translation to french of ninox code (functions) doesn't work.
Steven
-
Thanks a lot Steven, you are right : it works now !
-
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
-
Becarefull to use this, better make a backup first before trying this out:
for i in range(3825, 4349) do delete(i) end
Steven
-
Sorry, it should be:
for i in range(3825,4349) do delete(record('Votre nom de table',i)) end
Steven
-
Thanks Steven.
How does the script understand that (3825,4349) means from 3825 to 4349 and not 3825 and 4349 ?
-
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. -
I tried your function but I get :
"this formula can't modify datas"
-
-
You can use this code in a button or in the console
-
Et ensuite, vous pouvez retirer le bouton.
-
Thanks Steven.
Why some formulas work with a button and others don't ?
-
Thanks.
Strange : only the 450 has been deleted…
(By the way is it possible to go back after having push on a button ?)
-
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
- 1477Views