Excel - parent-child from a list of values - excel

I've a list a values (column-1) which contains multiple parents and childs levels and I need to associate in another column which is the parent of each cell.
Any ideas on how to do that easily in excel?
really thanks!
COLUMN-1 COLUMN-2
**A
A.01** **A**
**A.01.01** **A.01**
A.01.01.01 **A.01.01**
A.01.01.01.01 A.01.01.01
A.01.01.01.02 A.01.01.01
A.01.01.01.03 A.01.01.01
A.01.01.01.04 A.01.01.01
A.01.01.02 **A.01.01**
A.01.01.02.01 A.01.01.02
A.01.01.02.02 A.01.01.02
A.01.01.02.03 A.01.01.02
A.01.01.02.04 A.01.01.02
A.01.01.03 **A.01.01**
A.01.01.03.01 A.01.01.03
A.01.01.03.02 A.01.01.03
A.01.01.03.03 A.01.01.03
A.01.01.03.04 A.01.01.03
FINAL GOAL

Jos Woolley's approach looks likely.
For how to do it, see How can I perform a reverse string search in Excel without using VBA? (adapating . for spaces)

Related

Combine Two or more named ranges (with formulas) to one named range (array)

I am trying to use formula.1 to get data from the Data model and I have managed to use O7:P7 as an array in the Cubermember function.
like this:
This is sample data.
=CUBEVALUE("ThisWorkbookDataModel",CUBEMEMBER("ThisWorkbookDataModel",{"[Table1].[A1].&[A]","[Table1].[A2].&[D]"}),CUBEMEMBER("ThisWorkbookDataModel","[Measures].[Sum of A3]"))
O7 = "[Table1].[A1].&[A]"
P7 = "[Table1].[A2].&[D]"
formula.1 =CUBEVALUE("ThisWorkbookDataModel",CUBEMEMBER("ThisWorkbookDataModel",O7:P7),CUBEMEMBER("ThisWorkbookDataModel","[Measures].[Sum of A3]"))
This works, But I want to make the array dynamic with named ranges for both variables.
like this:
NamedRange1: ="[Table1].["&A2&"].&["&A1&"]"
NamedRange2: ="[Table1].["&B2&"].&["&B1&"]"
CombinedRange: must be an array with (NamedRange1 and NamedRange2)
I hope I have explained what I want.
I anyone can help that would be grand :)
enter image description here
Use CHOOSE:
=CUBEVALUE("ThisWorkbookDataModel",CUBEMEMBER("ThisWorkbookDataModel",CHOOSE({1,2},NamedRange1,NamedRange2)),CUBEMEMBER("ThisWorkbookDataModel","[Measures].[Sum of A3]"))

How to convert the following data to table format?

I have a 2 column data in the following format where Name is a string and Location is an array seperated with commas
Name------Location
John---------A,B,C,D
Paul----------E,F,G,H
I want to convert it to the following format
Name--------Location
John-----------A
John-----------B
John-----------C
John-----------D
Paul------------E
Paul------------F
Can someone suggested how can I achieve this ?
Thanks in advance.
There are many ways to accomplish this. One option is to use Split, along the following lines:
Location = "A,B,C,D"
LocationList = Split(Location, ",")
That will populate LocationList with an array of individual locations. You can then loop through the individual locations and generate your output.

Dynamically change the column name in a custom expression using $map in Spotfire

I have a property that contains a list of column names and I want to create a custom expression using the $map function, like this
$map("Sum(${myproperty}) as [${myproperty}]", ",")
However, I would like to change the column names dynamically when they contain a given string.
I have tried the following, which however doesn't work as it returns the expression between []
$map("Sum(${myproperty}) as [if(Find('string',${myproperty}),'new name', 'old name')]"), ",")
I have also tried the following, but it seems that $map() does not accept Concatenate()
$map(Concatenate("Sum(${myproperty}) as [",
if(Find('string',${myproperty}),'new name', 'old name'), "]"),
",")
Is it possible to realize what I am trying to do in Spotfire?
This post has an example ironpython script that can be used to change column headers, using document properties.
The script looks like this:
col=ActivedataTable.Columns["CurrentColumnName"]
ColName= ActivedataTable.Columns[col.Name].Properties["ExternalName"]
col.Name= "New Name"
It perhaps doesn't quite answer your question, but hopefully is useful.

Using custom table to feed drop-down list datasource

Let's assume that I have Custom Table named Possible URL target parameters with code name xyz.PossibleTargets with 2 columns:
Explanation and Value.
How to feed drop-down field on page type with data to have Value (from table) as Value and Explanation as name in drop-down?
What I already tried and it is not working:
Generate value;name pairs divided by newline and place it as List of options:
z = ""; foreach (x in CMSContext.Current.GlobalObjects.CustomTables["xyz.PossibleTargets"].Items) {z += x.GetValue("Value"); z +=";"; z += x.GetValue("Explanation"); z += "\n" }; return z;
Validator do no allow me to do such trick.
Set option Macro expression and provide enumerable object:
CMSContext.Current.GlobalObjects.CustomTables["xyz.PossibleTargets"].Items
In Item transformation: {%Explanation%} and in Value column {%TargetValue%}.
This do not work also.
Dropdown configuration
How to do this correctly? Documentation and hints on the fields are not helpful.
Kentico v11.0.26
I think that you should do it without marking field as a macro. Just type there the macro. Take a look on screen
No need to use a macro, use straight SQL, using a macro only complicates what appears to be a simple dropdown list.
SELECT '', '-- select one --' AS Explanation
UNION
SELECT TargetValue, Explanation
FROM xyz_PossibleTargets -- make sure to use the correct table name
ORDER BY ExplanationText
This should populate exactly what you're looking for without the complication of a macro.

knex.raw with existing columns array using .first statement

Here is existing code:
knex("products")
.first("id", "name", "ingredients")
...
So, currently it just uses array of column names.
Now I want to add calculated column here. It would consists of "constant" + product.id.
For product with id 1 it would be "api/v1/img/1".
For product with id 222 it would be "api/v1/img/222".
Alias of it should be "image".
I have to use knex.raw somehow. Do not understand how and what is the correct syntax to use it with .first().
I'm sorry, I'm unable to understand the question. What kind of result are you trying to achieve? maybe something like this?
knex("products")
.select('*', knex.raw(`'api/v1/img' || ?? as computed`, ['products.id']))
.first()
Like this: https://runkit.com/embed/9okme0czge8z

Resources