Assuming there is no Excel Constraints
then the following formula should work as per the tags posted. The following formula is a single input dynamic array formula.
=LET(
_data, A2:C10,
_object, FILTER(_data,INDEX(_data,,2)="Object"),
_property, UNIQUE(TOROW(TAKE(FILTER(_data,INDEX(_data,,2)="Property"),,-1)),1),
_rows, ROWS(_object),
_cols, COLUMNS(_property),
_name, SWITCH(LEFT(_property,2),"Ri","Ri","Le","Le","4-","Bo"),
_convert, HSTACK(_object,MAKEARRAY(_rows,_cols,LAMBDA(r,c,N(INDEX(LEFT(TAKE(_object,,-1),2),r)=INDEX(_name,c))))),
_headers, HSTACK(A1:C1,_property),
VSTACK(_headers,_convert))
_data
--> variable used for the data range, excluding the headers,
_object
--> Using FILTER()
returns the range which consists of only object
_property
--> Using FILTER()
returns the range which consists of only property
, and then taking the last column of that range with unique values transformed into columns from rows.
_rows
--> Using the ROWS()
to get number of object rows count.
_cols
--> Using COLUMNS()
to get the number of property columns count.
_name
--> Using the SWITHC()
function amending the names so as to match with the properties.
_convert
--> This uses a combination of HSTACK()
for one part and MAKEARRAY()
for another part. So the MAKEARRAY()
is returning an array with n
rows and n
columns based on the custom LAMBDA()
calculation applied, so what it does it just tries to do a BOOLEAN LOGIC
and returns 1
for TRUE
and 0
for FALSE
which is custom formatted as [=1]TRUE;;
. While using the HSTACK()
we are combining the return value of MAKEARRAY()
as well as the variable _object
.
_headers
--> as the name defines returning the respective headers for the array.
- Lastly, using
VSTACK()
to append both the arrays, here _headers
with _convert
.
One small change can be done by removing the _name
variable if you are sure about the property labels then,
• Instead of this
N(INDEX(LEFT(TAKE(_object,,-1),2),r)=INDEX(_name,c))
• Use this in place of that. remember to remove the _name
variable first.
N(INDEX(TAKE(_object,,-1),r)=INDEX(TEXTBEFORE(SUBSTITUTE(_property,"4","Bottom"),"-"),c))
Edit:
Updated Formula which returns as per the desired output:
=LET(
_Data, A1:C19,
_Mapping, {
"Right-Fixed", "Right";
"Left-Fixed", "Left";
"4-Legs", "Bottom";
"Front-Fixed", "Front";
"Back-Fixed", "Back";
"Folder", "Top"
},
_Headers, HSTACK(
TAKE(_Data, 1),
TOROW(
TAKE(_Mapping, , 1)
)
),
_Object, FILTER(
_Data,
INDEX(_Data, , 2) =
"Object"
),
_Rows, ROWS(_Object),
_Columns, COLUMNS(
DROP(_Headers, , 3)
),
_Matched, MAKEARRAY(_Rows,_Columns,LAMBDA(r,c, LET(
_Property, FILTER(INDEX(_Data,,3),(INDEX(_Object,r,1)=INDEX(_Data,,1))*(INDEX(_Data,,2)="Property")),
_MappedProps, VLOOKUP(_Property,_Mapping,2,0),
_MappedObj, VLOOKUP(INDEX(DROP(_Headers,,3),c),_Mapping,2,0),
N(OR((_MappedProps=_MappedObj)*(_MappedProps=INDEX(_Object,r,3))))))),
_Merged, HSTACK(
_Object,
_Matched
),
VSTACK(_Headers, _Merged)
)