<?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 Tabular Editor 2, C# Script - Movng created measures to a different table in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Tabular-Editor-2-C-Script-Movng-created-measures-to-a-different/m-p/4097630#M54738</link>
    <description>&lt;P&gt;Hello all,&lt;BR /&gt;&lt;BR /&gt;Trying to accomplish what in theory seems like a simple mechanic, but I have not found a way to accomplish this in any of the resources for generates DAX measures via C# Scripts in Tabular Editor!&lt;BR /&gt;&lt;BR /&gt;When generating a basic measure, say SUM of Sales Amount the C# Script is: (thank you&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/68724"&gt;@dotykier&lt;/a&gt;&amp;nbsp;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;/*
 * Title: Auto-generate SUM measures from columns
 * 
 * Author: Daniel Otykier, twitter.com/DOtykier
 * 
 * This script, when executed, will loop through the currently selected columns,
 * creating one SUM measure for each column and also hiding the column itself.
 */
 
// Loop through all currently selected columns:
foreach(var c in Selected.Columns)
{
    var newMeasure = c.Table.AddMeasure(
        "Sum of " + c.Name,                    // Name
        "SUM(" + c.DaxObjectFullName + ")",    // DAX expression
        c.DisplayFolder                        // Display Folder
    );
    
    // Set the format string on the new measure:
    newMeasure.FormatString = "0.00";

    // Provide some documentation:
    newMeasure.Description = "This measure is the sum of column " + c.DaxObjectFullName;

    // Hide the base column:
    c.IsHidden = true;
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;However, this code generates the measure within the Table of the selected column, i.e. the "Sales" table.&lt;BR /&gt;&lt;BR /&gt;I would like to generate the Measure in a seperate table called "Calculations", or move it to a different table after it has been generated but I cannot crack how to achieve this.&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;Aaron&lt;/P&gt;</description>
    <pubDate>Tue, 13 Aug 2024 12:36:20 GMT</pubDate>
    <dc:creator>Aaron_C</dc:creator>
    <dc:date>2024-08-13T12:36:20Z</dc:date>
    <item>
      <title>Tabular Editor 2, C# Script - Movng created measures to a different table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Tabular-Editor-2-C-Script-Movng-created-measures-to-a-different/m-p/4097630#M54738</link>
      <description>&lt;P&gt;Hello all,&lt;BR /&gt;&lt;BR /&gt;Trying to accomplish what in theory seems like a simple mechanic, but I have not found a way to accomplish this in any of the resources for generates DAX measures via C# Scripts in Tabular Editor!&lt;BR /&gt;&lt;BR /&gt;When generating a basic measure, say SUM of Sales Amount the C# Script is: (thank you&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/68724"&gt;@dotykier&lt;/a&gt;&amp;nbsp;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;/*
 * Title: Auto-generate SUM measures from columns
 * 
 * Author: Daniel Otykier, twitter.com/DOtykier
 * 
 * This script, when executed, will loop through the currently selected columns,
 * creating one SUM measure for each column and also hiding the column itself.
 */
 
// Loop through all currently selected columns:
foreach(var c in Selected.Columns)
{
    var newMeasure = c.Table.AddMeasure(
        "Sum of " + c.Name,                    // Name
        "SUM(" + c.DaxObjectFullName + ")",    // DAX expression
        c.DisplayFolder                        // Display Folder
    );
    
    // Set the format string on the new measure:
    newMeasure.FormatString = "0.00";

    // Provide some documentation:
    newMeasure.Description = "This measure is the sum of column " + c.DaxObjectFullName;

    // Hide the base column:
    c.IsHidden = true;
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;However, this code generates the measure within the Table of the selected column, i.e. the "Sales" table.&lt;BR /&gt;&lt;BR /&gt;I would like to generate the Measure in a seperate table called "Calculations", or move it to a different table after it has been generated but I cannot crack how to achieve this.&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;Aaron&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 12:36:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Tabular-Editor-2-C-Script-Movng-created-measures-to-a-different/m-p/4097630#M54738</guid>
      <dc:creator>Aaron_C</dc:creator>
      <dc:date>2024-08-13T12:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Tabular Editor 2, C# Script - Movng created measures to a different table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Tabular-Editor-2-C-Script-Movng-created-measures-to-a-different/m-p/4097670#M54740</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Would this do the trick?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var measureTable = Model.Tables["Measure Table"]; // Replace "Measure Table" with your desired table name

foreach(var c in Selected.Columns)
{
    var newMeasure = measureTable.AddMeasure(
        "Sum of " + c.Name,                    // Name
        "SUM(" + c.DaxObjectFullName + ")",    // DAX expression
        c.DisplayFolder                        // Display Folder
    );
    
    // Set the format string on the new measure:
    newMeasure.FormatString = "0.00";

    // Provide some documentation:
    newMeasure.Description = "This measure is the sum of column " + c.DaxObjectFullName;

    // Optionally, hide the base column:
    c.IsHidden = true;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 12:57:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Tabular-Editor-2-C-Script-Movng-created-measures-to-a-different/m-p/4097670#M54740</guid>
      <dc:creator>mariussve1</dc:creator>
      <dc:date>2024-08-13T12:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Tabular Editor 2, C# Script - Movng created measures to a different table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Tabular-Editor-2-C-Script-Movng-created-measures-to-a-different/m-p/4097716#M54741</link>
      <description>&lt;P&gt;You godsend!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;That's worth writing a small blog on now &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 13:18:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Tabular-Editor-2-C-Script-Movng-created-measures-to-a-different/m-p/4097716#M54741</guid>
      <dc:creator>Aaron_C</dc:creator>
      <dc:date>2024-08-13T13:18:43Z</dc:date>
    </item>
  </channel>
</rss>

