Is it possible to make a view with a top 10 only?
P

With my array I can insert an item() in the criteria but I need to tell the criteria != to all value in my array...that s where the issue came out...

Ninox Profile

Well, you've mentioned a couple of issues not just one. 1) You want to copy array values to your table rank field. 2) You want to sort by a combination of your rank fields. Correct?

P

I want to make a view table that show only a top 5 value or so. But to show only a number of value, I need to filter after filtering. 

let say: let A := sort((select Achats).total_vente);
let B := null;
let j := number_show_1 - 1;
let x := cnt(A) - 1;
for i in range(x, j) do
let B := B + item(A, i);
B
end

this way I get the good value but in an array...I need to make a new filter but I don t know how to use it in filter...

(select Achats)[total_vente = B]

 

The 'rank' field is only to be able to filter but like I said if I change any of the filter option, I need a new 'rank' with the new filter... 

thanks!

Ninox Profile

For what it's worth, I'm pretty sure item(A, i) is returning a string so what you are doing is concatenating items from the array to B which is a string.

 

It seems to me all you need to do is resequence your Rank field occasionally using the code for the button @Mconneen already gave you.

P

yes that wath I m trying to do for now! I create a main table composite to all other... then I create my view table on the main form with 2 selection field. Here my code inside the selection field 'on update' formula... seems to have an issue with it! I come close but there s something...

let sort := null;  
let type_atel := text('Type atelier'); ------> 'selection field 1'
let sort := if text(Type_produit) = "Accessoire" then  ----> variable with sorting value...
"total_accessoires"
else
if text(Type_produit) = "Epice" then
"total_aliments"
else
"total_vente"
end
end;
let r := cnt(select Achats);
let a := cnt((select Achats)[text(Atelier.'Type d''Atelier') = text(type_atel)]);
for p in select Achats do
p.(Rank := null)----> set all rank to null before to set it...
end and for p in (select Achats)[text(Atelier.'Type d''Atelier') = text(type_atel)] order by text(sort) do
p.(Rank := a);
a := a - 1
end

 

 

can you help me with this? Thanks a lot!

P

seems to be the 'sort' that I m trying to use a variable to order values... should have a way to do it...

Ninox Profile

Umm, I've never seen code where 2 for-loops were combined with "and". Also, you can't sort by proxy and I'm pretty sure you can't filter by proxy either. Meaning, you can't use a variable like "text(sort)" in the "order by" of a select statement.

 

You will have to test for each condition and then use the literal version of the correct select statement.

Ninox Profile

I trust the lack of DESC in an oversight?

Ninox Profile

Hi Plafontain, 

may be these functions can help you:

 

sort(array)
 - sorts an array in ascending order

rsort(array) - sorts an array in descending order

 

 

Best, Jörg

1 2
Reply