Dynamically change column names and corresponding measures

Is there a way to make column names dynamic so when changed from the source, corresponding measurements will also be updated? I’ve figured out how to prevent refresh crashes but I still have to go through and manually change the old column names used within measures.

Bumping this post for more visibility from our experts and users.

HI @bricek6 ,

While waiting for other members to jump in, I suggest using the forum search to discover if your query has been asked before by another member.

Here are some topics that might help:

Thanks!

how drastically are your column names changing?

If it’s just a matter of either “January” or “Jan” in your column names - then that can be fixed in Power Query (and is where I would recommend making the change)

But if your names are completely unknown to you with each update - that could be more problematic.

Can you provide an example of how the data is changing?

Hi Brice,
are only the names changing and the structure is unchanged?
If the position of the columns is unchanged there is a SIMPLE method:

  1. Demote the headers
  2. Remove the first row
  3. Rename ALL columns {“Column1”, “Needed Name”}

That’s all.
Regards,
Matthias

Hello @bricek6

Did the responses above help solve your query?

If not, can you let us know where you’re stuck and what additional assistance you need?

If it did, please mark the answer as the SOLUTION.

Thank you

The column names were changed at the source in SQL. I used variables and set the M code to equal the new names. The problem is that I still had to go through all of my measures and manually update the column names from the old names to the new names.

Would this method update all of the measures as well? I did not have to use the first row as headers.

from my research, it is not possible updating automatically.

Agreed, if changes are made to column names in your dataset, it will not update your measures automatically.

I recommend using a third party tool like Tabular Editor to make updating the measures easier.

Since the change was made at the SQL source, hopefully you’ll only need to make this change the one time.

1 Like

Hello @bricek6

Good to see that you are having progress with your inquiry. Did the response from @Heather help you solve your inquiry?

If it does, kindly mark the answer as the solution to your query.

If not, how far did you get and what kind of help do you need further?

Hello @bricek6,

just following up if you still need assistance with solving your inquiry.

Please don’t forget if your question has been answered within the forum it is important to mark your thread as ‘solved’.

Hi Brice,

=> This means you have the SAME columns, just with a different name.
No big deal. Why do you want to change the measures? Simply change the names back to what you had before and you are good.

To get rid of the new unwanted names just do this:

  1. Demote the headers
  2. Remove the first row

Now you can simply rename each column {“Column1”, “Old Name1”}, {“Column2”, “Old Name2”}, …

Too much work? Then you can alternatively do the following with an Old download with the correct names:

  1. Demote the headers
  2. Keep the first row
  3. Append the table from above
  4. Promote headers

Two easy alternatives and no need to change any measures.

Regards,
Matthias

1 Like

Hi @bricek6,

I hope you’re doing well! I wanted to follow up on your question and check if everything has been resolved to your satisfaction. If there is anything else we can do to assist you, please don’t hesitate to let us know.

Additionally, I wanted to ask if it would be alright to close this thread at this point. Of course, if you have any further questions or concerns, we’re here to help and keep the conversation going. Just let us know what would work best for you.

Thank you for your time and attention, and I look forward to hearing back from you soon.

Best regards,

The measure do not work when they reference the old column names. I want them to automatically change inside the measure when I change the column name. I am currently doing the Tab 3 lesson and it looks like it might be easier to change all of the measures there. Thank you

1 Like

Sure, you can close the thread. I am still confused as to efficiently change the measure with the new column names without having to go through each one manually. Luckily I don’t have very many. But if I had a 100 down the road and for some reason the column name needed to be changed in the sql server, I want to be able to go through and update all of the measures.

Is there a reason why you cannot rename the columns to force them back to the column names you have in your measures? That is easier than trying to update your measures. @Matthias provided a way to do that in his reply. Using that approach, no matter what the column names are in the source, you force them to be what you want/need them to be in your data model.

1 Like

The end user wants the column names used from the source and a standardized naming convention. Every visualization header needs to be the names from the source. I already have a ton of measures written with the old names. I want to force them all to be what’s from the source now.

Will the columns names continue to change over time, or is this a one-time change?

Might change, but this should be the final names. I already manually changed them all to the new names. I was just seeing if there was an efficient way to do so. You would think that power bi would save the column names to be more object oriented, so one change would update the chain of events.

1 Like

I’m not sure if I understand. This would allow the refresh but keep the old column names? This would work but then I would have to change the names on every visualization I make.

Thank you all for the help!