Help with Parent child relationship

Hi anyone who can help. I need a way to display a view to show products at parent level with a list of who has that particular product shown in the child view. At the moment I have products setup so that the user can see what they have in stock but I want to be able to show the product and who else has it in stock? I have some tables Products, Employees, Stock in, Stock Out. I want a way to display the employee who has that particular part in stock shown in the child view of the products table?

So it would kind of look like this

Parent = [Product name]
Child = List of [Employee names] and [Stock level]

thanks

Antony

0 42 1,633
42 REPLIES 42

I assume you are using a slice at this moment with your existing view. What condition rule are you using with that slice?

Hi Aleksi,

I currently have a view that shows products that the user logged on has in stock. I have a ref rows from the stock in, and stock out tables, with a sum that works out the stock level of the current employee logged on. it doesnโ€™t show names of employee. i guess i can create a view from the employees table with a ref rows on the stock in and stock out but I do not want to display it that way. I need a list of products names (Parent) and then a list of employees with the stock level of that particular product as a child list. So when I view a product it has a list of employees names and the stock level, if that is possible?

at the moment I have a slice from the Products table which is called โ€œMy Stockโ€ with a row filter condition of [Stock Level]>0. in the underlying Products table I have a ref rows on Stock in and stock out tables, and then a sum which looks like this to give me the stock level

SUM(SELECT([Stock In][Qty In], ([Booked To Email] = USEREMAIL()))) - SUM(SELECT([Stock Out][Qty Out], ([Booked Out By Email] = USEREMAIL())))

thanks

When you have a table view with products and you click one product, do you want to open a table view of your related employees OR do you want to see related list in productโ€™s detail view?

Hi aleksi,

I want to see a list of related products in products detail view. i only need to see the employee name and the stock level they hold of that particular product that has been selected for the main view.

thanks

Antony

IF I have understood your structure correctly, you should first sum the stock level in your โ€œStock Inโ€ table. Then you could create a virtual list in your โ€œProductsโ€ table with a formula likeโ€ฆ
SELECT(Stock In[KeyColumn],[ProductID]=[_THISROW].[ProductID])

Hi Aleksi,

this worked but i get to see all of the rows of stock in. What i need is to just see one row per employee who has that particular stock item, and the qty, is this possible?

Thanks

How about grouping that inline view with the employee?

Hi Aleksi,

that just shows the rows still but with the employee name as the group heading, if you mean โ€œGroup byโ€. so all I did was group by the employee name, is that what you meant?

Thanks

Yes I mean Group by.

Hi Aleksi,

In that case, it still shows the rows of the Stock in transactions. Is there another approach I could use as I cannot see this working for me?

thanks

Would you please give me the account ID and app name. I believe thatโ€™s the quickest wayโ€ฆ

Account ID = 326317
App Name = Stock Control

It seems that you have removed that virtual list? Can you put it back as you tried so it would be easier to see the affect, thanks.

Ok, now under Products as โ€œSite Stockโ€. if you look at โ€œMy Stockโ€ View its there. if you look at record Tridonic PC 1x28-33 LO DD Combo. you can see the multiple rows

thanks

Would you please close the editor. I will show you what I mean. Is that possible?

Editor now closed, thanks

For some reason Group By twice is not working with the Detail/Inline view correctly. I need to check what could be the reason for that. I believe it would be the solution in your case. Closest I could think ofโ€ฆ I created a โ€œlistโ€ with a virtual column. Please check it.

Thanks Aleksi, looks fine for what I need. Appreciate the help.

Did i get the sum correct in โ€œStock inโ€ for stock level, as doesnโ€™t seem to work out correctly?
I think the โ€œMove Stockโ€ table is throwing things out due to the fact that it wont show in the stock in virtual column due to being in a different table
Antony

I didnโ€™t check that formula. You should probably check itโ€ฆ when you sync the app, all virtual columns are calculated so if the formula is correct, it should work.

Hi Aleksi,

I donโ€™t think the way I have structured it this way it is going to work as when I move stock it moves from one person to the other in the move stock table and I have sums to work out the value based on who it moves from and to based in that table. This means it will not show under Stock in virtual columns you have created for me. Do you think it would be better to have a โ€œmove fromโ€ column in the stock in table so that the virtual columns you created will show employees who have the stock?

Sorry, but it is little bit difficult to give you the correct answer because I should go deep into your app so I could understand your whole process. Inventory apps are not the most easiest one in generally.

Are you able to look at it?

Thanks

I also have the sum incorrect, can you see where I have gone wrong?

SUM(SELECT(Stock In[Qty In],[Booked To]=[Booked To]))- SUM(SELECT([Related Stock Out][Qty Out],[Booked Out By]=[Booked Out By]))- SUM(SELECT([Related Moved Stock][Move Qty], ([Move From] = [Move From])))+ SUM(SELECT([Related Moved Stock][Move Qty], ([Move To] = [Move To])))

The best way you can test your expression is if you do it one by one. Then itโ€™s easier to say if that part is correct or not. In generally the syntax is probably not correct because you have this [Booked To]=[Booked To]. Itโ€™s not a real evaluation because the result is always true. It would be the same if you type it like 1=1. If you have used the same column name in both tables, it should be something likeโ€ฆ
SUM(SELECT(Stock In[Qty In],[Booked To]=[_THISROW].[Booked To]))

Thanks, I will try it now

ok, so that just added up every row not by Product, but by employee name. Do I have a ref wrong?
My key is โ€œin IDโ€

Hi @Aleksi,

I managed to get my sums to work and the formula you did to display who has stock and the amount. The issue with this is with my โ€œMoved Stockโ€ table. In this table, i have 2 columns โ€œMove Fromโ€ and โ€œMove Toโ€, also โ€œMove Qtyโ€. If that employee hasnโ€™t had stock of that item i.e exists in the โ€œStock Inโ€ table, the sums donโ€™t work and also they will not show up in the formula you did because it is based on entries of the โ€œStock Inโ€ table. Is there a way around this?

My sums for out the stock levels are:
SUM(SELECT(Stock In[Qty In],AND([Product Name]=[_THISROW].[Product Name],[Booked To]=[_THISROW].[Booked To])))-SUM(SELECT([Related Stock Out][Qty Out],AND([Product Name]=[_THISROW].[Product Name],[Booked Out By]=[_THISROW].[Booked To])))-SUM(SELECT([Related Moved Stock][Move Qty],AND([Product Name]=[_THISROW].[Product Name],[Move From]=[_THISROW].[Booked To])))+SUM(SELECT([Related Moved Stock][Move Qty],AND([Product Name]=[_THISROW].[Product Name],[Move To]=[_THISROW].[Booked To])))

seems long winded but it works, almost!

First in generallyโ€ฆ If I have understood your workflow correctly, you would not need to type [Product Name]=[_THISROW].[Product Name] if you are already using the syntax like [Related Stock Out][Qty Out] because itโ€™s already a list of related products and their quantities. Are you able to do the same with this SUM(SELECT(Stock In[Qty In],โ€ฆ)) as well? Like [Related Stock In][Qty In]?

If your employee doesnโ€™t have any โ€œStock Inโ€, but products from โ€œMove Toโ€, should your sum calculation cover that situation as well?

Hi Aleksi,

Yes to the first question. I will try changing the sums.
Yes to the second question and this is why. The stock is generally van stock which employees would keep on their vans, but I do also have a central store area which I would need to move stock from there to their vans. Also if someone hasnโ€™t had stock of something before and they need to move from employee to employee, or from central store to employee then at present the sums would not work. I would have to create a blank entry for each product name and employee in the โ€œStock Inโ€ table for it to work, and thatโ€™s a lot of entries, especially when new stock gets added. I would need to do this process again and again.

Isnโ€™t your formula already doing that? I meanโ€ฆ SUM(SELECT([Related Moved Stock][Move Qty],[Move To]=[_THISROW].[Booked To]))

Yes, but as you suggested in the previous post i may have a situation where the employee doesnโ€™t have any items in โ€œStock Inโ€ table but I will need to move items to them from someone else โ€œMoveโ€ table. Sums will not work out in โ€œStock Levelโ€ unless โ€œProduct Nameโ€ and โ€œEmployee Nameโ€ exist in the โ€œStock Inโ€ table.
I have also changed the sums which work apart from on the โ€œStock Inโ€ table. I need to refer to also the โ€œproduct nameโ€ in the select expression for it to work otherwise it just adds up every entry from the employee.

My only advice is then that you need to sum those records from โ€œMoved Stockโ€ table as well.

Thanks Aleksi,

Will give it a try. What about this formula CONCATENATE([BOOKED TO]," ",[STOCK LEVEL]). Can I combine this with the moved stock to show also in the products table, as you did yesterday?

Yes you can do that as well.

How would I combine the 2 to show only one column in products table. Current expression looks like this
SUBSTITUTE(CONCATENATE(SELECT(Stock In[Stock by Employee],[Product Name]=[_THISROW].[Product Name],TRUE))," , โ€œ,CONCATENATE(โ€
"))

Before doing that, let me find out why the grouping twice is not working correctly with the inline view. If we can fix that issue, itโ€™s an easier way in your case.

Ok, do I need to come out of the app now?

No, thatโ€™s not needed.

Hi @Aleksi,

Thanks for your help but I think Iโ€™m going to restructure the app slightly as the whole stock moving process is a bit clunky.
Would you know if Iโ€™m able to copy to a row twice from a single action button?
Iโ€™m thinking of using 1 table to move stock in and out, but with the move part Iโ€™m going to need to create 2 rows 1 for the โ€œmove toโ€ and 1 for the โ€œmove fromโ€. I would have a โ€œstatusโ€ column with values set like โ€œmove fromโ€, โ€œmove toโ€, "Stock in, โ€œstock outโ€ each time I hit an action button for each part of the process?

Thanks

Ok thanks

Top Labels in this Space