sorting a tree-like structure with VBA - excel

I have a sheet that has a tree like structure, where the level of a node is determined by the indentation, as you can see below.
My objective is to iterate over this sheet, and sort it given some hardcoded order (f.e., Mike:1, November:2, Lima:3, Oscar:4, Tango:5). In my situation, I want my output to be:
Mike
November
Lima
ALL OF LIMA'S CHILDREN AND GRANDCHILDREN
Oscar
ALL OF OSCAR'S CHILDREN AND GRANDCHILDREN
Tango
Where the tree structure is preserved, and the values associated with every name on the columns to the right are also maintained. How would I go about implementing this in VBA?

Related

Excel 365 Getting a Drop down with right Parent for Child

I have a family tree with 4 generations. I have put them into named groups of Parent and Child, for a child in 1st generation becomes a Parent in 2nd generation and so forth.
I can easily, pending some rules, decide what Parent resides in 1st generation and a list of Children from Parent.
When you work with this for a while you start to recognise a system of Children in the 4th generation, and you then just select that Child and from that choise I can then select (XLOOKUP, VLOOKUP) who is the Parent of selected Child.
My problem comes when my children Peter, Joe, Beatrice, Jim, Joe suddenly gets an overlap. The 2 Joes which normally have 2 different parents now only have 1, due to LOOKUP only finding the first solution.
I can easily make a FILTER of which Parents are linked to a Child, and list them seperately but I need that FILTER inside a Data Validation (Drop Down). I have tried the INDIRECT solution and it didn't work as intended. FILTER(Parent;Child=D5)
The function I'm using right now is XLOOKUP(D1;Child;Parent;"not found";0;1) , that works brilliantly when the family tree is straight up and clear. I select the Child, it finds the Parent, which in turn find the (Grand)Parent, etc. When I do find a Joe it returns the Parent of the 1st Joe in the system, messing up the family trees.
Optimally I would have a Drop Down of the possible Parents of this Joe and then the family tree would continue.
(There's a client and level of IP involved. The specific word is 'Other' and several trees are using the word to describe a group of products. Due to IP I can't change any names or make it Joe 1, Joe 2, etc)
I have 1000s of rows of this, when I've selected a family/product-line for a row that row is done. I can't feasible allocate that Drop Down out. The filter needs to be incl in the Drop Down/Data validation menu. Each time the client returns with a new Workbook, I'd prefer I just copy-paste the logic and easily covering the 1000s of rows.
4 generations and 5 families. If for each generation there'd be a drop down of Parents for a Child, that would solve for those families with a Joe.
TRANSPOSE(FILTER(Parent;Child=D1))
Actually the solution was a support outsider, but not column, but rather row wise.
But what about the indetermined length of possible parents?
That is where the spill functionality comes in. Data validation with just the first cell, and reference finished with a #. The # makes it a spill. =C1#
But a Data validation is normally vertical, how do you turn it?
Excel does that by auto.

Fix the structure of the SSRS Matrix

I have been working on a small project. I am trying to display all the results in the same row without NULL values. I've written a small expression to remove the Null values already "=IIF(IsNothing(Fields!RegisterNo.Value),True,False)". However, the rows seem to be moving one level down as it is displayed in the picture ResultMatrix1. I want the results to be on the same level. Can you please tell me if this is possible and how I can achieve it. Is it something to do with the groupings or something else?
Design Groupings
By default, when you create a table, there is a Row Group called "Details" that is not actually grouped by anything. This causes it to produce one row for each row from the dataset. Since you are trying to group these, you need to make sure that innermost group is grouped by your Staff Ref No.
In the lower-right cell, you may need to change the expression to use a Max function. This will simply avoid arbitrarily showing blanks when they happen to be sorted before a real value within that group.

Dynamic Range with Categorical Variables

I'd like to sort a time series of exam performance by one of three categories:
Ideally, a function would sort the scores by "difficulty" while still preserving chronological order. I'd like to do this without filters etc. Something like this is very close, but not quite there. Do I need to use dynamic ranges? Or can I just define data ranges in the table dialog with VLOOKUP or INDEX/MATCH?
I'm thinking a bar graph would be the easiest way to illustrate the data, but I'm open to suggestions. New scores are added every day, with varying difficulties.
Here is the spreadsheet if anyone would like to look it over.
EDIT:
The output visualization could be, for example, a clustered bar graph, but with only one label per category. The idea is that I'd like to preserve chronological order without necessarily having to mark it on the graph.
Would there, for instance, be a quick-and easy and formula-driven way to put these 14 and 17 values for "score" all together under one label? I feel like 17 bar graphs clustered too closely would be hard to read.
I realize this is more of a formatting than a formula issue, but I appreciate input with regards to both.
I would recommend you add a Table over the data in the workbook. One for verbal and one for math. The upside is that it will automatically grow with your data as you add new rows. This is very helpful because charts and other things will automatically refer to the new data. Add one with CTRL+T or Insert->Table on the Ribbon.
Once you have the Table, you can easily do the sorting bit by adding a two column sort onto the Table. This menu is accessible by right clicking in the Table and doing Sort->Custom Sort. Again, the Table is nice here because it will only sort the data within it (not the whole sheet) and will remember your settings. This lets you add new data and simply do Data->Reapply to get it to sort again. Your sort on Difficulty is going to be alphabetic unless you add a number at the front. Here is the sorting step:
With this done, you can create a quick chart based on that data. For the "implicit chronology" you can simply plot score vs. difficulty for all of them since they are sorted.
To get closer to that matrix style display, you can easily create a PivotTable based on this Table and let it do the organizing by date/difficulty. Here is the result of that. I am using Average as the aggregation function since it appears that no dates have more than 1 score. If they did, it would be a better choice than Sum.

Getting entries of child grids of currently expanded row in `igHierarchicalGrid`

I am trying to achieve a functionality in which what i want is to get the data of children of the row, that is currently being expanded. I came through the Example on Ignite UI Help Forum, but it does not help me with the issue. The Example is demonstrated in this fiddle. The
ui.owner.allChildren().data().igGrid.dataSource.data()
is giving me data of all expanded rows children. I want this functionality to achieve at every level i.e. Suppose a row at level 2 is expanded, then, I want to be able to get the data of child grid associated with that row.
In the example above mentioned fiddle, I want to be able to get the data of Food row children, when food is expanded, and of Beverages row children, when this is expanded.
I am not able to figure out, how can i filter out those entries, which do not belong to a particular row.
Thanks
I managed to find a way for you how to extract the specific child grid data:
$(ui.parentrow.context).find("table[data-childgrid=true]")
.data()
.igGrid
.dataSource
.data();
This should still be made easier to be accessed using the event arguments more directly!

Book ordering comparison between spreadsheets for existing catalogue of a Library

I have recently asked this question of google's spreadsheet page.
I a significant data comparison problem I would like to solve. It relates to purchasing books for a Library. We have a catalogue of over 11,000 books. When we order new books we need to compare our proposed purchases to the current stock. Currently we can manually compare them to our catalogue, very laboriously book by book.
We need to do 3 things to make our life easier -
1 easily clean out bad data/characters in the ISBN's - these are either spaces, - (hyphen's) or . (period mark or full stops). A simple formula to run over all ISBN fields would be great.
2 I need to compare data between 1 spreadsheet with 11,000 books in it (current library stock), a second with up to 1000 books in it (currently on order) and finally the third currently active one (about to be ordered) with 50 to 200 books listed in it.
All spreadsheets use the same column configuration as below
Library orders
Title Author Publisher ISBN (long version) US$ UKgpd HK$ Other$ P/O no. Date ordered
UNNATURAL SELECTION MARA HVISTENDAHL Public Affairs Publishing; Reprint edition (May 1, 2012) 978610391511
Finally, the out put of these comparisons should quickly and easily identify on what lines we have matches. and what type of match it is, Author only, Author and Title, or Author, title and ISBN etc for all the possible combinations. To make this easier assume spreadsheet 1 is an unalterable master table, with spreadsheet two similar. It is really only on Spreadsheet 3 we need to be clear if we are starting to reorder materials.
If it is possible to have these as different sheets in a workbook it would be ideal. The only additional feature is that any scripts that run need to be able to cope with spreadsheet 1 increasing in size as new acquisitions arrive and are included. Both spreadsheets 2 and 3 will vary (increase and decrease) as the ordering process proceeds.
Finally the absolute ideal would be for this comparison process to be instant (live) and ongoing as data is included.
If anyone would like to take this on 3 Library staff will be eternally grateful.
regards
Nick
This would be very much easier had you one sheet rather than three (simply add a column to each existing sheet to show whether in stock, on order or to be ordered – three individual letters would be sufficient, then append each of the smaller two files to the largest). Then for example you could apply Conditional Formatting to highlight duplicates one column at a time (Author, Title etc). Apart from the initial data cleansing it would mean in the future switching ‘between sheets’ would merely involve changing a one-letter flag. Filtering would allow you and your colleagues to appear to have three separate sheets and if anyone asks for a particular Title the search would be one-time, not in triplicate.
Also, http://www.microsoft.com/en-gb/download/details.aspx?id=15011 may be of interest, also =SUBSTITUTE.And with data validation you would prevent entry of a new ISBN that already is in your list.

Resources