Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Column reference as variable

Hey guys,

 

I would like to replace a static value (in that case a column reference) by an variable:

daniel_st_0-1648644631740.png

I tried it the following way which didn't work:

 

"RemovedColumns[#"""& HierachyAttribute &"""]"


Would appreciate any hints 🙂

Thanks Dan

1 ACCEPTED SOLUTION
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

You can try following (this will depend upon your context)

Table.Column(RemovedColumns,HierachyAttribute)

 

Example is below

    RemovedColumns = Table.RemoveColumns(#"Changed Type",{"Country"}),
    HierachyAttribute = "Sales Channel",
    #"Added Custom" = Table.AddColumn(RemovedColumns, "Custom", each Table.Column(RemovedColumns,HierachyAttribute))

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

works like a charm! Thanks @Vijay_A_Verma 

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

You can try following (this will depend upon your context)

Table.Column(RemovedColumns,HierachyAttribute)

 

Example is below

    RemovedColumns = Table.RemoveColumns(#"Changed Type",{"Country"}),
    HierachyAttribute = "Sales Channel",
    #"Added Custom" = Table.AddColumn(RemovedColumns, "Custom", each Table.Column(RemovedColumns,HierachyAttribute))

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors