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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

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
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.