Show Columns dynamically

kensel

New Member
Joined
Feb 8, 2019
Messages
1
Hello,

I'm looking for a way, preferably Power Query, to have a sheet with a table or text file with column names that are visible when loading a spreadsheet.

For example I have a csv with the following columns:

[TABLE="width: 920"]
<colgroup><col></colgroup><tbody>[TR]
[TD]
Caption​
[/TD]
[/TR]
[TR]
[TD]
IP_Address​
[/TD]
[/TR]
[TR]
[TD]
AgentPort​
[/TD]
[/TR]
[TR]
[TD]
Allow64BitCounters​
[/TD]
[/TR]
[TR]
[TD]
AvgResponseTime​
[/TD]
[/TR]
[TR]
[TD]
BlockUntil​
[/TD]
[/TR]
[TR]
[TD]
BufferBgMissThisHour​
[/TD]
[/TR]
[TR]
[TD]
BufferBgMissToday​
[/TD]
[/TR]
[TR]
[TD]

[/TD]
[/TR]
</tbody>[/TABLE]

I have created a Sheet with the table:
[TABLE="width: 984"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Column[/TD]
[TD]Show[/TD]
[/TR]
[TR]
[TD]Caption[/TD]
[TD="align: center"]TRUE[/TD]
[/TR]
[TR]
[TD]IP_Address[/TD]
[TD="align: center"]TRUE[/TD]
[/TR]
[TR]
[TD]AgentPort[/TD]
[TD="align: center"]FALSE[/TD]
[/TR]
[TR]
[TD]Allow64BitCounters[/TD]
[TD="align: center"]FALSE[/TD]
[/TR]
[TR]
[TD]AvgResponseTime[/TD]
[TD="align: center"]FALSE[/TD]
[/TR]
[TR]
[TD]BlockUntil[/TD]
[TD="align: center"]FALSE[/TD]
[/TR]
[TR]
[TD]BufferBgMissThisHour[/TD]
[TD="align: center"]FALSE[/TD]
[/TR]
[TR]
[TD]BufferBgMissToday[/TD]
[TD="align: center"]FALSE[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD]I would like the Load query to load the Columns that show true. I have the following query to get the list of columns to keep but I don't know how to have the CSV load query remove the extra columns.

let​
Source = Excel.CurrentWorkbook(){[Name="ColumnList"]}[Content],​
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column", type text}, {"Show", type logical}}),​
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Show] = true)),​
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Show"})​
in​
#"Removed Columns"​

I found a stack overflow that shows how to hide a column that I might look at trying to modify with my beginner VBA skills to hide the unwanted columns. https://stackoverflow.com/questions/45110022/excel-macro-hide-columns-based-on-string

Possible Addition once working: I might expand it and add a profile column to make it so that specific columns are shown depending on the profile.

Reason: I would like to make this so that I can have one workbook that imports the data from a single regularly updated CSV and show different sets of data depending on what I'm working on.

Thank you,
Kensel


[/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top