<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic SEMPY - Remame Column Semantic Model in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/SEMPY-Remame-Column-Semantic-Model/m-p/4360247#M58971</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm able to generate a semantic model using sempy lab's&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://semantic-link-labs.readthedocs.io/en/stable/sempy_labs.directlake.html#sempy_labs.directlake.generate_direct_lake_semantic_model" target="_self"&gt;generate_direct_lake_semantic_model&lt;/A&gt;&amp;nbsp;, but once I do that, I would love to rename the colum within the model to "nice" names, as our database names are not so nice.&amp;nbsp; Is there way either through the TOM or another way to do so?&amp;nbsp; &lt;A href="https://semantic-link-labs.readthedocs.io/en/stable/sempy_labs.tom.html#sempy_labs.tom.TOMWrapper.update_column" target="_self"&gt;update_column&lt;/A&gt; looks like a great way to update a column's attributes, but not the name itself.&amp;nbsp; Am I missing something somewhere?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I know this can be done, as the UI support does support the concept!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for your help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 12 Jan 2025 16:26:00 GMT</pubDate>
    <dc:creator>kwenzelmms</dc:creator>
    <dc:date>2025-01-12T16:26:00Z</dc:date>
    <item>
      <title>SEMPY - Remame Column Semantic Model</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SEMPY-Remame-Column-Semantic-Model/m-p/4360247#M58971</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm able to generate a semantic model using sempy lab's&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://semantic-link-labs.readthedocs.io/en/stable/sempy_labs.directlake.html#sempy_labs.directlake.generate_direct_lake_semantic_model" target="_self"&gt;generate_direct_lake_semantic_model&lt;/A&gt;&amp;nbsp;, but once I do that, I would love to rename the colum within the model to "nice" names, as our database names are not so nice.&amp;nbsp; Is there way either through the TOM or another way to do so?&amp;nbsp; &lt;A href="https://semantic-link-labs.readthedocs.io/en/stable/sempy_labs.tom.html#sempy_labs.tom.TOMWrapper.update_column" target="_self"&gt;update_column&lt;/A&gt; looks like a great way to update a column's attributes, but not the name itself.&amp;nbsp; Am I missing something somewhere?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I know this can be done, as the UI support does support the concept!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for your help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2025 16:26:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SEMPY-Remame-Column-Semantic-Model/m-p/4360247#M58971</guid>
      <dc:creator>kwenzelmms</dc:creator>
      <dc:date>2025-01-12T16:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: SEMPY - Remame Column Semantic Model</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SEMPY-Remame-Column-Semantic-Model/m-p/4360274#M58972</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="640154" data-lia-user-login="kwenzelmms" class="lia-mention lia-mention-user"&gt;kwenzelmms&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Seems like smepy.update_column cannot change the column name. Not sure if there any other function which can perform this task, But here are a couple of suggestions&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. with TMSL, you can run this script either from tabular editor or SSMS to update mutiple column names programitically&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
  "operations": [
    {
      "operationType": "update",
      "object": {
        "database": "YourDatasetName",
        "table": "YourTableName",
        "column": "OldColumnName"
      },
      "property": "name",
      "value": "NewColumnName"
    }
  ]
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. first get the definition (bim file) of your semantic model -&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;sempy_labs.get&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;_semantic_model_from_bim&lt;BR /&gt;and then update it with this function&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;sempy_labs.&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;update_semantic_model_from_bim&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;A href="https://semantic-link-labs.readthedocs.io/en/stable/sempy_labs.html" target="_blank" rel="noopener"&gt;https://semantic-link-labs.readthedocs.io/en/stable/sempy_labs.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need a Power BI Consultation? Hire me on &lt;A href="https://bit.ly/4d3oy4s" target="_blank" rel="noopener"&gt;Upwork&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Connect on &lt;A href="https://www.linkedin.com/in/tharun-kumar-ravikrindhi/" target="_blank" rel="noopener"&gt;LinkedIn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV class=""&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;DIV class=""&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;DIV style="border-radius: 1px; padding: 10px; border: solid #cccccc 1px; background: #fafafa no-repeat right 10px center;"&gt;&lt;BR /&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;STRONG style="margin-right: 3px;"&gt;&lt;STRONG style="margin-right: 3px;"&gt;&lt;STRONG style="margin-right: 3px;"&gt;Did I answer your question? Mark my post as a solution!&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;STRONG style="margin-right: 3px;"&gt;&lt;STRONG style="margin-right: 3px;"&gt;&lt;STRONG style="margin-right: 3px;"&gt;If I helped you, click on the Thumbs Up to give Kudos.&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;
&lt;P style="padding: 0; margin: 5px 50px 0 0;"&gt;Proud to be a Super User!&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;img /&gt;&lt;/DIV&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2025 17:03:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SEMPY-Remame-Column-Semantic-Model/m-p/4360274#M58972</guid>
      <dc:creator>tharunkumarRTK</dc:creator>
      <dc:date>2025-01-12T17:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: SEMPY - Remame Column Semantic Model</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SEMPY-Remame-Column-Semantic-Model/m-p/4360287#M58973</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the tip.&amp;nbsp; I'll try that direction and let you know how it goes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kris.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2025 17:33:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SEMPY-Remame-Column-Semantic-Model/m-p/4360287#M58973</guid>
      <dc:creator>kwenzelmms</dc:creator>
      <dc:date>2025-01-12T17:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: SEMPY - Remame Column Semantic Model</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SEMPY-Remame-Column-Semantic-Model/m-p/4360303#M58974</link>
      <description>&lt;P&gt;Hi,&amp;nbsp; Your idea got me off to the right start and on to the solution.&amp;nbsp; Thanks!&amp;nbsp; Here is the prototype that works, the dictionary lookup code is sketcy, but it's Sunday here, and I'm just having fun playing on a snowy afternoon.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; &amp;nbsp;I took this out of the fabric notebook I was using to piece it together:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from sempy_labs.directlake import generate_direct_lake_semantic_model
from sempy_labs import get_semantic_model_bim, update_semantic_model_from_bim


#Intention will be to call one gold lakehouse is created.
semantic_model_name = lakehouse_name+"KAW"

#from: https://semantic-link-labs.readthedocs.io/en/stable/sempy_labs.directlake.html#sempy_labs.directlake.generate_direct_lake_semantic_model
generate_direct_lake_semantic_model(
    dataset=semantic_model_name,
    workspace="DataScienceProd",
    lakehouse_tables=lakehouse_tables,
    lakehouse=lakehouse_name,
    overwrite=True,
    refresh=True
)

model_bim = get_semantic_model_bim(dataset=semantic_model_name)

def rename_column_in_table(data, table_name, old_column_name, new_column_name):
    # Get the list of tables
    tables = data.get('model', {}).get('tables', [])
    for table in tables:
        # Check if the current table matches the table_name
        if table['name'] == table_name:
            # Iterate over columns and rename the column if it matches
            for column in table.get('columns', []):
                if column['name'] == old_column_name:
                    column['name'] = new_column_name
                    column['sourceColumn'] = new_column_name  # Optional, update the source column
    return data

updated_bim= rename_column_in_table(
    model_bim,
    table_name='reconcileitem',
    old_column_name='study_name',
    new_column_name='better study name'
)

from pprint import pprint
pprint(updated_bim)

update_semantic_model_from_bim(semantic_model_name, updated_bim)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For context this is for some pharamceutical study data that is for highly standardized datasets that got to powerbi visualizations.&amp;nbsp; The dataset got to the FDA.&amp;nbsp; They have short and unfriendly names.&amp;nbsp; The idea is to use the standard's data dictionary to reamame them with the semantic model so we can visualize, yet on the lakehouse side keep the original column name so biometrics and datascience can continue to work as usual.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next step to make production worthy.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Connect with me on linkedin if you wish -&amp;nbsp;&lt;A href="https://www.linkedin.com/in/kriswenzel/" target="_blank"&gt;https://www.linkedin.com/in/kriswenzel/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2025 18:44:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SEMPY-Remame-Column-Semantic-Model/m-p/4360303#M58974</guid>
      <dc:creator>kwenzelmms</dc:creator>
      <dc:date>2025-01-12T18:44:41Z</dc:date>
    </item>
  </channel>
</rss>

