Forum

Notifications
Clear all

Extract a value and return column header

5 Posts
4 Users
0 Reactions
210 Views
(@kevinl96)
Posts: 14
Eminent Member
Topic starter
 

Hi,

 

i am struggling with the following;

The columns having a value between 0 - 4 
If value is 1 or higher, I want to have the column header,

In the screenshot, I added 4 column with value 1,2,3,4.
there is need the result of the value.

 

So for example in row 9

In my value 1 I need 'Transito' (value in c9)

And in my value 2 I need 'Type_agaricus'  (Value in H9)

 

Voorbeeld.pngwaarde-vinden.png

 

Anyone have a smart idea to extract this?

 
Posted : 15/02/2022 9:20 am
Alan Sidman
(@alansidman)
Posts: 222
Member Moderator
 

Will there ever be more than three columns with numbers between 1 and 4?

 
Posted : 16/02/2022 12:59 am
(@bluesky63)
Posts: 162
Estimable Member
 

Hi,

easier to do it in Power Query

Worksheet one is your source which consist only raw columns,  bring into Power Query,  the following are the M Code

let

    Source = Table1,

    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Index", "Groep", "Latijns"}, "Attribute", "Value"),

    #"Added Custom" = Table.AddColumn(#"Unpivoted Other Columns", "Custom", each if [Value]>= 1 then [Attribute] else ""),

    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] <> "")),

    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Value"}),

    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Attribute]), "Attribute", "Custom"),

    #"Sorted Rows" = Table.Sort(#"Pivoted Column",{{"Index", Order.Ascending}}),

    #"Removed Columns1" = Table.RemoveColumns(#"Sorted Rows",{"Index"}),

    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns1",Headers)

in

    #"Renamed Columns"

 

You can amend the values in some of the columns to more than 1,  and goto second tab the output table, right click and refresh to see the updated result

Rgds

 
Posted : 16/02/2022 4:36 am
(@debaser)
Posts: 836
Member Moderator
 

For a formula version, in C2:

=IFERROR(INDEX($G$1:$Y$1,AGGREGATE(15,6,1/($G2:$Y2>0)*(COLUMN($G2:$Y2)-COLUMN($G2)+1),COLUMNS($A$1:A$1))),"")

and copy across and down.

 
Posted : 16/02/2022 6:20 am
(@kevinl96)
Posts: 14
Eminent Member
Topic starter
 

Good solutions Velouria and Chris,

Chris, i am to nooby for understand what you did there =) but for now it worked.

 

Velouria, thanks tho! 

 

i also figured out later, that the =filter worked here

 

=FILTER(G$1:Y$1;G2:Y2>0;"")
 
Posted : 16/02/2022 7:39 am
Share: