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
PeRoma
Frequent Visitor

create column with DAX using paramters as identifier for column

Hi all,

 

I would like to copy a column using DAX. The problem is that the column is selected as a parameter.

Example:

Nummer AA    BB    CC

1123111 
2 222 
3345  
4456 456
5567 876
6 333333
7789444 
8900555 
910111011 
101122  
111233  
12  654
131455 543
141566777432
15 888 
1617881788321
1718991110 

 

I have defined a field parameter containing the column names "AA", "BB" and "CC". The column is selected by this parameter.

There is another table (T2) containing only the numbers. 

Is there a way to define a new column in T2 that contains the values of the selected column?

 

My final goal is to copy 2 columns and compare the values. Any idea to do this without the creation of the columns is highly wellcome. I want to present a table visual containing both selected columns and a column for comparison.

 

Thank you for any help or hint.

 

PeRoma

5 REPLIES 5
StrategicSavvy
Resolver II
Resolver II

Hi,

I think it is not possible in DAX to reference dynamically columns in calculatd tables because they always need to have data copied. I think If you want this you will need to copy all the columns AA, BB, CC and then you can dynamically reference this new calculated table. 

 

Hope it helps!

Hi Savvy,

Thank you for your reply. I was afraid that this would not be possible. But gave me some hope that I can reach my final goal: My goal is, to compare the columns. In the example above there would be TRUE for row 4, 9 and 16 when comparing AA wigh BB. Is it possible to do this comparison e.g. via function EXACT and reference the columns at run time?

Thank you once more for your reply.

Best regards

peroma

Hi PeRoma,

 

I think with this goal in mind you can use measure with 2 parametes defined in disconnected table.

Here is the screenshot:

create column with DAX using paramters as identifier for column.png

 

Attached pbix:

https://drive.google.com/file/d/1CbcK9erUvMcMJ6jFqvS-6OTR9LdRrTSt/view?usp=sharing 

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: www.linkedin.com/in/lukasz-kozdron 

Sahir_Maharaj
Super User
Super User

Hello @PeRoma,

 

Can you please try this:

CalculatedTable = 
ADDCOLUMNS(
    SUMMARIZE(T1, T1[Nummer]),
    "SelectedValue", SWITCH(TRUE(),
        SelectedColumn = "AA", CALCULATE(SUM(T1[AA])),
        SelectedColumn = "BB", CALCULATE(SUM(T1[BB])),
        SelectedColumn = "CC", CALCULATE(SUM(T1[CC])),
        BLANK()
    )
)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Hi Sahir,

Thank you for your response.

But sorry, this does not answer my question. My goal to copy  the column into table T2. All the values.
If I e.g. select column "AA" from table T1- at run time by any means I want to copy only this column into table T2. The problem is, I don't know how to reference a column dynamically with a parameter, measure or by any other means. This referenced column should then be copied into table T2.

 

In other words: I have no problem to reference columns within DAX by just naming them. But I want to reference to a column that is only selected at run time. And I want to copy this column.

 

Thank you for your effort. Do you have any idea based on this explanation?

 

Best

 

peroma

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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.