HI, I build an app to insert order but i would like to have a limit to insert new products, i tried to insert in BEHAVIOR this rule COUNT(Products[Id Products],([User] = [Id Products].[User])) >= 0 but the rule is not correct. How can i resolve it?
Are you trying to count this in a same table or in another one?
in this table…in reality I would need a rule that counts the number of products inserted and the number of products that can be purchased …i’ve another table “CONTRACTS”; in “CONTRACTS” table i’ve the the maximum number of products that can be purchased; in “PRODUCTS” table i inserted a virtual column with LOOKUP the maximum products that can bu purchased
Do you want to just check the quantity of products that can be purschased or do you need to deduct existing orders from this table?
i need a counter…from maximum to zero. I tried also to insert NOT <0, with a virtual column to count the inserted products, but the action works because the counter also counts below zero (-1)
Not 100% sure but probably…
LOOKUP([_THISROW].[Id Products],“Concrats”,“Id Products”,“Maximum”) - SUM(SELECT(Products[Quantity],[Id Products]=[_THISROW].[Id Products])) >= [Quantity]
no, it doesn’t work, i tried to change the forumla:
i added a virtual column to count the inserted products in PRODUCT TABLE
LOOKUP([_THISROW].[Customers],“Contracts”,“Customers”,“N° Products Included”) - COUNT(SELECT(Products[N° inserted products],[Customers]=[_THISROW].[Customers])) >= [N° Inserted products]
If i use this rule in another virtual column (without >= [N° Inserted products]) the result is 0 , than is correct. I tried also to insert a virtual column"PLUGGABLE" in PRODUCTS TABLE to give me result Y/N if result is zero, and in ADD ACTION the rule [_THISROW].[PLUGGABLE]=Y but it doesn’t works
Maybe i’ve to commutate the virtual column in a normal row or i’ve to put the virtual column in CONTRACT table. What do you think?
Without knowing your table/column structure it’s litle bit difficult to say what would be the exact formula in your case.
Hi Aleksi…can you help me with this ticket?
Sorry… I have somehow missed your reply. Let me check this one… soon.
Is the customer in your Products table a supplier?
What you mean? i try to explain the process: The customers stipulate a contract to put in the app some products, i’ve 3 kinds of contract with different quantities the customers could insert; for eg, if the customer stipulate a contract with 20 products, i need the “add button” disappears when the customer has inserted his quantities. Than, i tried different solution: i’ve 3 virtual column, 1st with counter, 2nd lookup how many products have customer in his contract, 3rd subtract and if result is “0” give me N …i tried to insert different conditions in behavior but all attempts were in vain
Gotcha. So every time when the customer makes an order, they need to add a record into your products table, correct?
exactly, i tried to insert behavior (INSERTABLE = NO), or a more complex search function if the result from zero but do not work(IF (COUNT (FILTER( …=0) and also [Insertable Column]<=0 (
this is not correct because the counter give the result -1,-2 etc)
How do you identify the user? Does the customer need to sign in?
I done also the slices view (ROW FILTER CONDITION: USEREMAIL()=[USER])
Does your products and Contracts table contain customer’s email address?
If they do, you could use the formula with the system generated “Add” action button.
COUNT(Products[ID Products],[User]=USEREMAIL()))<LOOKUP(USEREMAIL(),“Contracts”,“User”,“Number of products included”)