TabularEditor / TabularEditor3

Bug reports, feature requests, discussion and documentation for Tabular Editor 3 (commercial version).
61 stars 7 forks source link

Macro context disappeared #1151

Closed hayescode closed 3 weeks ago

hayescode commented 7 months ago

Description

My team has ~35 macros that we use in different contexts within the TOM explorer (Model, Table, Measures, etc.). A few versions ago (we're on 3.11 now) we noticed that our macro "actions" are not visibile, but they still exist. In order to add the actions back we discovered that opening the Macro pane, clicking Edit Macro and saving makes it visible again, but this is tedious with so many macros plus it only applies to the open model. Reopening TE3 removes them again so we have to do the whole process again.

Tabular Editor 3 Version

3.11.0

Screenshots

image

Edit Macro -> Save image

Now visible: image

Steps to Reproduce

No response

Expected behavior

No response

Crash Report

N/A - If you need our configs from %localappdata% we can provide.

Windows Version

11

mlonsk commented 7 months ago

Hi @hayescode I am unfortunately unable to reproduce the issue. If you are able to share your %localappdata% with us through support@tabulareditor.com that would be appricated so we can try to investigate further.

hayescode commented 3 months ago

Hi @mlonsk - Sorry for forgetting to reply. I am still having this issue in 3.13. Here are some of my Macro actions that don't show up.

Localappdata: image

{
  "Actions": [
    {
      "Id": 0,
      "Name": "Calculation Group\\Add with Time Items",
      "Enabled": "true",
      "Execute": "//Source = https://www.pbiusergroup.com/communities/community-home/digestviewer/viewthread?MessageKey=a2885009-fe23-4557-bbc2-65ffc8384c88&CommunityKey=b35c8468-2fd8-4e1a-8429-322c39fe7110&tab=digestviewer\n\nvar dateColumn = \"Dim_Calendar[Date]\"; //Change this!!!\nvar valueFormat = \"\\\"\" + \"$0,0.00;($0,0.00)\" + \"\\\"\";\nvar percentFormat = \"\\\"\" + \"0.00%\" + \"\\\"\";\n\nvar cg = Model.AddCalculationGroup(\"Calc_Time Intelligence\");\n\ncg.AddCalculationItem(\"Current\", \"SELECTEDMEASURE()\");\ncg.AddCalculationItem(\"MTD\", \"TOTALMTD(SELECTEDMEASURE(), \"+dateColumn+\")\");\ncg.AddCalculationItem(\"YTD\", \"TOTALYTD(SELECTEDMEASURE(), \"+dateColumn+\")\");\ncg.AddCalculationItem(\"PY\", \"CALCULATE(SELECTEDMEASURE(), SAMEPERIODLASTYEAR(\"+dateColumn+\"))\");\ncg.AddCalculationItem(\"YoY Δ\", \"SELECTEDMEASURE() - (CALCULATE(SELECTEDMEASURE(), SAMEPERIODLASTYEAR(\"+dateColumn+\")))\");\ncg.AddCalculationItem(\"YoY Δ %\", \"DIVIDE(SELECTEDMEASURE(),(CALCULATE(SELECTEDMEASURE(), SAMEPERIODLASTYEAR(\"+dateColumn+\"))),BLANK())-1\");\n\n//Now Format the items.\n\nvar calc_group = (Model.Tables[\"Calc_Time Intelligence\"] as CalculationGroupTable);\n\ncalc_group.CalculationItems[\"Current\"].FormatStringExpression = valueFormat;\ncalc_group.CalculationItems[\"MTD\"].FormatStringExpression = valueFormat;\ncalc_group.CalculationItems[\"YTD\"].FormatStringExpression = valueFormat;\ncalc_group.CalculationItems[\"PY\"].FormatStringExpression = valueFormat;\ncalc_group.CalculationItems[\"YoY Δ\"].FormatStringExpression = valueFormat;\ncalc_group.CalculationItems[\"YoY Δ %\"].FormatStringExpression = percentFormat;\n\n",
      "Tooltip": "teest",
      "ValidContexts": "Table"
    },
    {
      "Id": 1,
      "Name": "DAX\\Evaluate Measures by Column",
      "Enabled": "true",
      "Execute": "//Source = https://data-goblins.com/power-bi/tabular-editor-query-data?s=03 \n\n// Instructions\n  // ------------\n  // 1. Save this script as a macro with a context of 'Column' and 'Measure'\n  // 2. Configure a keyboard shortcut for the macro (i.e. ALT + C) if using Tabular Editor 3\n  // 3. Select any combination of columns & measures related in the model & run the script\n  // 4. The output will return the evaluation result of all selected objects, assuming it is valid  \n  \n  \n  // Get column names\n  var _ColumnsList = new List<string>();\n  foreach ( var _SelectedColumn in Selected.Columns )\n  {\n      _ColumnsList.Add(_SelectedColumn.DaxObjectFullName);\n  }\n  string _Columns = String.Join(\",\", _ColumnsList );\n  \n  \n  // Get measure names\n  var _MeasuresList = new List<string>();\n  var _MeasuresOnlyList = new List<string>();\n  foreach ( var _SelectedMeasure in Selected.Measures )\n  {\n      // Create a syntax for evaluating objects when measures + columns are selected     \n      _MeasuresList.Add( @\"\"\"@\" + _SelectedMeasure.Name + @\"\"\"\" );\n      _MeasuresList.Add(_SelectedMeasure.DaxObjectFullName);\n  \n      // Create a syntax for evaluating objects when only measures are selected\n      _MeasuresOnlyList.Add( \n          \"\\nADDCOLUMNS (\\n{\" + \n          @\"\"\"\" + _SelectedMeasure.Name + @\"\"\"\" + \n          \"},\\n\" + \n          @\"\"\"\" + \"Result\" + @\"\"\"\" + \n          \",\\n\" + \n          _SelectedMeasure.DaxObjectFullName + \")\");\n  }\n  string _Measures = String.Join(\",\", _MeasuresList );\n  \n  \n  // Results differ depending on how many columns, measures are selected\n  int _NrMeasures = Selected.Measures.Count();\n  int _NrColumns = Selected.Columns.Count();\n  \n  \n  // ----------------------------------------------------------------------------------------//\n  // Result if a combination of measures & columns are selected\n  if ( _NrMeasures > 0 && _NrColumns > 0 )\n  {\n      // Summarize selected columns + measures with DAX\n      string _dax = \n          \"SUMMARIZECOLUMNS ( \" + _Columns + \", \" + _Measures + \")\";\n  \n      // Return output in pop-up\n      EvaluateDax(_dax).Output();\n  }\n  \n  \n  // ----------------------------------------------------------------------------------------//\n  // Result if no columns and more than 1 measure are selected\n  else if ( _NrColumns == 0 && _NrMeasures > 1 )\n  {\n      // Evaluate each measure as a separate row\n      string _dax = \n          \"SELECTCOLUMNS( UNION ( \" +                    // SELECTCOLUMNS to re-name cols, UNION to combine rows\n          String.Join(\",\", _MeasuresOnlyList ) + \"),\" +  // Concatenate list of measure evaluations\n          @\"\"\"\" + \"Measure Name\" + @\"\"\"\" +               // Rename 1st col \"Measure Name\"\n          \", [Value],\" +                                 // \n          @\"\"\"\" + \"Measure Result\" + @\"\"\"\" +             // Rename 2nd col \"Measure Result\"\n          \", [Result])\" ;                                // \n  \n      // Return output in pop-up\n      EvaluateDax(_dax).Output();\n  }\n  \n  \n  // ----------------------------------------------------------------------------------------//\n  // Result if no columns and exactly one measure are selected\n  else if ( _NrColumns == 0 && _NrMeasures == 1 )\n  {\n      // Evaluate each measure as a separate row\n      string _dax =                                      \n          \"SELECTCOLUMNS( \" +                           // SELECTCOLUMNS to re-name cols\n          String.Join(\",\", _MeasuresOnlyList ) + \",\" +  // Concatenate list of measure evaluations \n          @\"\"\"\" + \"Measure Name\" + @\"\"\"\" +              // Rename 1st col \"Measure Name\" \n          \", [Value],\" +                                //  \n          @\"\"\"\" + \"Measure Result\" + @\"\"\"\" +            // Rename 2nd col \"Measure Result\"\n          \", [Result])\" ;                               // \n  \n      // Return output in pop-up\n      EvaluateDax(_dax).Output();\n  }\n  \n  \n  // ----------------------------------------------------------------------------------------//\n  // Result if only columns and no measures are selected\n  else\n  {\n      // Summarize selected columns with DAX\n      string _dax = \n          \"SUMMARIZECOLUMNS ( \" + _Columns + \")\";\n  \n      // Return output in pop-up\n      EvaluateDax(_dax).Output();\n  }",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    },
    {
      "Id": 2,
      "Name": "DAX\\Evaluate Measures",
      "Enabled": "true",
      "Execute": "//Source = https://docs.tabulareditor.com/te2/Useful-script-snippets.html\n\nvar dax = \"ROW(\" + string.Join(\",\", Selected.Measures.Select(m => \"\\\"\" + m.Name + \"\\\", \" + m.DaxObjectFullName).ToArray()) + \")\";\nEvaluateDax(dax).Output();\n",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    },
    {
      "Id": 3,
      "Name": "DAX\\Modify DAX",
      "Enabled": "true",
      "Execute": "//Source: https://github.com/ab-inbev-beertech/beertech-bi-automation-assets/blob/main/Tabular%20Editor/Automation%20Scripts/Measures%20-%20Modify%20Selected%20Measure%20Expressions.csx\n/* \n    Script Name: Modify Selected Measure Expressions\n    Function: Loops through all currently selected measures (in T3) and replaces the \n           FromString with the ToString in the measures expression property\n    Author: Jerid Fortney\n    Last Modified: 12/06/2021\n    Examples: \n             FromString = \"'Total Volume'[Amount]\";\n             ToString = \"'factCommercialP&L'[Amount]\"\n\t\t\t Before:\tTotal Volume = CALCULATE(\n\t\t\t\t\t\t\t\t\t\t\t\tSUM('Total Volume'[Amount]),\n\t\t\t\t\t\t\t\t\t\t\t\t'P&L Lines'[P&L Name] =  \"Total Volume\"\n\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t After:\t \tTotal Volume = CALCULATE(\n\t\t\t\t\t\t\t\t\t\t\t\tSUM('factCommercialP&L'[Amount]),\n\t\t\t\t\t\t\t\t\t\t\t\t'P&L Lines'[P&L Name] =  \"Total Volume\"\n\t\t\t\t\t\t\t\t\t\t\t\t )\n*/\n            \nvar FromString = \"old_string\";\nvar ToString = \"new_string\";\nforeach (var m in Selected.Measures)\n    {\n        m.Expression = m.Expression.Replace(FromString,ToString);\n        \n    }\n",
      "Tooltip": "",
      "ValidContexts": "Measure"
    },
    {
      "Id": 6,
      "Name": "General\\Add Description to all objects",
      "Enabled": "true",
      "Execute": "//souce = https://github.com/PowerBI-tips/TabularEditor-Scripts/blob/main/Basic/DAX%20Comment%20to%20Measure%20Description.csx\n\n//foreach (var m in Model.AllMeasures) {\n//  m.Description = m.Expression;\n//}\n\n//foreach (var c in Model.AllColumns) {\n//  c.Description = c.Name;\n//}\n\nforeach (var t in Model.Tables) {\n  t.Description = t.Name;\n}",
      "Tooltip": "",
      "ValidContexts": "Model"
    },
    {
      "Id": 7,
      "Name": "Dependencies\\Find All Dependencies",
      "Enabled": "true",
      "Execute": "//Source = https://docs.tabulareditor.com/te2/Useful-script-snippets.html\n/*\nLet's say you have a large, complex model, and you want to know which measures are potentially affected by changes to the underlying data.\n\nThe following script loops through all the measures of your model, and for each measure, it outputs a list of tables that measure depends on - both directly and indirectly. The list is outputted as a Tab-separated file.\n*/\n\nstring tsv = \"Measure\\tDependsOnTable\"; // TSV file header row\n\n// Loop through all measures:\nforeach(var m in Model.AllMeasures) {\n\n    // Get a list of ALL objects referenced by this measure (both directly and indirectly through other measures):\n    var allReferences = m.DependsOn.Deep();\n\n    // Filter the previous list of references to table references only. For column references, let's get th\n    // table that each column belongs to. Finally, keep only distinct tables:\n    var allTableReferences = allReferences.OfType<Table>()\n        .Concat(allReferences.OfType<Column>().Select(c => c.Table)).Distinct();\n\n    // Output TSV rows - one for each table reference:\n    foreach(var t in allTableReferences)\n        tsv += string.Format(\"\\r\\n{0}\\t{1}\", m.Name, t.Name);\n}\n    \ntsv.Output();   \n// SaveFile(\"c:\\\\MyProjects\\\\SSAS\\\\MeasureTableDependencies.tsv\", tsv); // Uncomment this line to save output to a file\n",
      "Tooltip": "",
      "ValidContexts": "Model"
    },
    {
      "Id": 5,
      "Name": "General\\Format all measures",
      "Enabled": "true",
      "Execute": "/*\nhttps://github.com/ab-inbev-beertech/beertech-bi-automation-assets/blob/main/Tabular%20Editor/Automation%20Scripts/Measures%20-%20Format%20all%20Measures.csx\n\nSource: https://github.com/TabularEditor/TabularEditor3/issues/306#issuecomment-983124779\nFormatting of calculated tables and calculated columns is unsupported in Power BI Desktop as at 25 Aug 2021\nand will be ignored if unsupported features are not enabled in Tabular Editor\n*** USE ONLY IN TE3 ***\nThis method makes multiple calls to daxformatter.com in TE2, however, in TE3 this will always use the internal formatter\n(https://github.com/TabularEditor/TabularEditor3/issues/307#issuecomment-977597528)\n*** Known Bugs ***\nAs at 2 Dec 2021 this always uses the short line format: https://github.com/TabularEditor/TabularEditor3/issues/314\n*/\n\n// options begin\n\nvar useShortFormat = true;\nvar insertSpaceAfterFunctionName = true;\nvar insertLeadingLine = true;\n\n// options end\n\nvar leadingLine = \"\";\nif (insertLeadingLine) {\n  leadingLine = \"\\r\\n\";\n}\n\nforeach(var m in Model.AllMeasures) {\n  m.Expression = leadingLine + FormatDax(m.Expression, shortFormat: useShortFormat, skipSpaceAfterFunctionName: !insertSpaceAfterFunctionName);\n}\n\nforeach(var i in Model.AllCalculationItems) {\n  i.Expression = leadingLine + FormatDax(i.Expression, shortFormat: useShortFormat, skipSpaceAfterFunctionName: !insertSpaceAfterFunctionName);\n}\n\nforeach(var t in Model.Tables.Select(x => x as CalculatedTable).Where(x => x != null)) {\n  t.Expression = leadingLine + FormatDax(t.Expression, shortFormat: useShortFormat, skipSpaceAfterFunctionName: !insertSpaceAfterFunctionName);\n}\n\nforeach(var c in Model.AllColumns.Select(x => x as CalculatedColumn).Where(x => x != null)) {\n  c.Expression = leadingLine + FormatDax(c.Expression, shortFormat: useShortFormat, skipSpaceAfterFunctionName: !insertSpaceAfterFunctionName);\n}\n",
      "Tooltip": "",
      "ValidContexts": "Model"
    },
    {
      "Id": 4,
      "Name": "General\\Remove All Implicit Measures",
      "Enabled": "true",
      "Execute": "//Souce: https://github.com/PowerBI-tips/TabularEditor-Scripts/blob/main/Basic/Nuke%20All%20Implicit%20Measures.csx\n\n// Title: Nuke All Implicit Measures.csx\n// Author: @JamesDBartlett3\n// Description: Uses two methods to disable all Implicit Measures in the model\n\n// 1. Set \"Discourage Implicit Measures\" option in Model = true\nModel.DiscourageImplicitMeasures = true;\n    \n// 2. Set \"Summarize By\" property on all columns = AggregateFunction.None\nforeach(var column in Model.Tables.SelectMany(t => t.Columns)) {\n    column.SummarizeBy = AggregateFunction.None;\n}\n",
      "Tooltip": "",
      "ValidContexts": "Model"
    },
    {
      "Id": 8,
      "Name": "Measures\\Create Aggregation Measure",
      "Enabled": "true",
      "Execute": "// Creates a SUM measure for every currently selected column and hide the column.\n//Source = https://docs.tabulareditor.com/te2/Useful-script-snippets.html\n\n//Specify aggregation type\nvar aggType = \"Sum\";\n\n//Specify measure table\nvar measureTable = Model.Tables[\"_Measures\"];\n\n//Specify the display folder\nvar displayFolder = \"Aggregations\";\n\n\n\n//RUN\nforeach(var c in Selected.Columns)\n{\n    var newMeasure = measureTable.AddMeasure(\n        \"Sum of \" + c.Name,                    // Name\n        \"SUM(\" + c.DaxObjectFullName + \")\",    // DAX expression\n        displayFolder\n        //c.DisplayFolder                        // Display Folder\n    );\n    \n    // Set the format string on the new measure:\n    newMeasure.FormatString = \"0.00\";\n\n    // Provide some documentation:\n    newMeasure.Description = \"This measure is the sum of column \" + c.DaxObjectFullName;\n\n    // Hide the base column:\n    c.IsHidden = true;\n}\n",
      "Tooltip": "",
      "ValidContexts": "Column"
    },
    {
      "Id": 9,
      "Name": "Measures\\Create MTD",
      "Enabled": "true",
      "Execute": "//Source = https://docs.tabulareditor.com/te2/Useful-script-snippets.html\nvar dateColumn = \"Dim_Calendar[Date]\";\n// Month-to-date:\nforeach(var m in Selected.Measures) {\n    m.Table.AddMeasure(\n        m.Name + \" MTD\",                                       // Name\n        \"TOTALMTD(\" + m.DaxObjectName + \", \" + dateColumn + \")\",     // DAX expression\n        m.DisplayFolder                                        // Display Folder\n    );\n}\n",
      "Tooltip": "",
      "ValidContexts": "Measure"
    },
    {
      "Id": 10,
      "Name": "Measures\\Create PY Measures",
      "Enabled": "true",
      "Execute": "//Source = https://docs.tabulareditor.com/te2/Useful-script-snippets.html\nvar dateColumn = \"Dim_Calendar[Date]\";\n// Previous year:\nforeach(var m in Selected.Measures) {\n    m.Table.AddMeasure(\n        m.Name + \" PY\",                                       // Name\n        \"CALCULATE(\" + m.DaxObjectName + \", SAMEPERIODLASTYEAR(\" + dateColumn + \"))\",     // DAX expression\n        m.DisplayFolder                                        // Display Folder\n    );    \n}\n",
      "Tooltip": "",
      "ValidContexts": "Measure"
    },
    {
      "Id": 11,
      "Name": "Measures\\Create YoY Δ % Measures",
      "Enabled": "true",
      "Execute": "// Create YoY delta % measures\n//Source = https://docs.tabulareditor.com/te2/Useful-script-snippets.html\nforeach(var m in Selected.Measures) {\n    m.Table.AddMeasure(\n        m.Name + \" YoY%\",                                       // Name\n        \"DIVIDE([\" + m.Name + \" YoY], [\" + m.Name + \" PY], BLANK())\",    // DAX expression\n        m.DisplayFolder                                         // Display Folder\n    ).FormatString = \"0.0 %\";                                   // Set format string as percentage\n}\n",
      "Tooltip": "",
      "ValidContexts": "Measure"
    },
    {
      "Id": 12,
      "Name": "Measures\\Create YoY Δ Measures",
      "Enabled": "true",
      "Execute": "// Create YoY delta measures\n//Source = https://docs.tabulareditor.com/te2/Useful-script-snippets.html\nforeach(var m in Selected.Measures) {\n    m.Table.AddMeasure(\n        m.Name + \" YoY Δ\",                                       // Name\n        m.DaxObjectName + \" - [\" + m.Name + \" PY]\",            // DAX expression\n        m.DisplayFolder                                        // Display Folder\n    );\n}\n",
      "Tooltip": "",
      "ValidContexts": "Measure"
    },
    {
      "Id": 13,
      "Name": "Measures\\Create YTD Measures",
      "Enabled": "true",
      "Execute": "//Source = https://docs.tabulareditor.com/te2/Useful-script-snippets.html\nvar dateColumn = \"Dim_Calendar[Date]\";\n// Creates a TOTALYTD measure for every selected measure.\nforeach(var m in Selected.Measures) {\n    m.Table.AddMeasure(\n        m.Name + \" YTD\",                                       // Name\n        \"TOTALYTD(\" + m.DaxObjectName + \", \" + dateColumn + \")\",     // DAX expression\n        m.DisplayFolder                                        // Display Folder\n    );\n}\n",
      "Tooltip": "",
      "ValidContexts": "Measure"
    },
    {
      "Id": 14,
      "Name": "Relationships\\Hide Columns on Many Side",
      "Enabled": "true",
      "Execute": "//Source: https://github.com/PowerBI-tips/TabularEditor-Scripts/blob/main/Basic/Hide%20columns%20on%20the%20many%20side%20of%20a%20relationship.csx\n/*\n * Title: Hide columns on the many side of a relationship  \n *\n * Author: Matt Allington, https://exceleratorbi.com.au  \n *\n * it is dangerous to use columns on the many side of a relationship as it can \n * produce unexpected results, so it is a best practice to hide these columns\n * to discourage their use in reports.\n */\n\n// Hide all columns on many side of a join\n\nforeach (var r in Model.Relationships)\n{ // hide all columns on the many side of a join\n    var c = r.FromColumn.Name;\n    var t = r.FromTable.Name;\n    Model.Tables[t].Columns[c].IsHidden = true;\n}\n",
      "Tooltip": "",
      "ValidContexts": "Relationship"
    },
    {
      "Id": 16,
      "Name": "Tables\\Create Field Parameter Table",
      "Enabled": "true",
      "Execute": "// Before running the script, select the measures or columns that you\n// would like to use as field parameters (hold down CTRL to select multiple\n// objects). Also, you may change the name of the field parameter table\n// below. NOTE: If used against Power BI Desktop, you must enable unsupported\n// features under File > Preferences (TE2) or Tools > Preferences (TE3).\n\n#r \"Microsoft.VisualBasic\"\nusing Microsoft.VisualBasic; \n//The order to select the columns is the order they'll be added to the Field Parameter table.\n\n//var suffix = \"KPI\"; //<--Change This!!!\n//var name = \"Parm_\" + suffix; //<--Change This!!!\n\nvar name = \"Parm_\" + Interaction.InputBox(\"Provide suffix for the field parameter table (Parm_{ENTER BELOW})\");\n\n\n//RUN CODE\nif(Selected.Columns.Count == 0 && Selected.Measures.Count == 0) throw new Exception(\"No columns or measures selected!\");\n\n// Construct the DAX for the calculated table based on the current selection:\nvar objects = Selected.Columns.Any() ? Selected.Columns.Cast<ITabularTableObject>() : Selected.Measures;\nvar dax = \"{\\n    \" + string.Join(\",\\n    \", objects.Select((c,i) => string.Format(\"(\\\"{0}\\\", NAMEOF('{1}'[{0}]), {2})\", c.Name, c.Table.Name, i))) + \"\\n}\";\n\n// Add the calculated table to the model:\nvar table = Model.AddCalculatedTable(name, dax);\n\n// In TE2 columns are not created automatically from a DAX expression, so \n// we will have to add them manually:\nvar te2 = table.Columns.Count == 0;\nvar nameColumn = te2 ? table.AddCalculatedTableColumn(name, \"[Value1]\") : table.Columns[\"Value1\"] as CalculatedTableColumn;\nvar fieldColumn = te2 ? table.AddCalculatedTableColumn(name + \" Fields\", \"[Value2]\") : table.Columns[\"Value2\"] as CalculatedTableColumn;\nvar orderColumn = te2 ? table.AddCalculatedTableColumn(name + \" Order\", \"[Value3]\") : table.Columns[\"Value3\"] as CalculatedTableColumn;\n\nif(!te2) {\n    // Rename the columns that were added automatically in TE3:\n    nameColumn.IsNameInferred = false;\n    nameColumn.Name = name;\n    fieldColumn.IsNameInferred = false;\n    fieldColumn.Name = name + \" Fields\";\n    orderColumn.IsNameInferred = false;\n    orderColumn.Name = name + \" Order\";\n}\n// Set remaining properties for field parameters to work\n// See: https://twitter.com/markbdi/status/1526558841172893696\nnameColumn.SortByColumn = orderColumn;\nnameColumn.GroupByColumns.Add(fieldColumn);\nfieldColumn.SortByColumn = orderColumn;\nfieldColumn.SetExtendedProperty(\"ParameterMetadata\", \"{\\\"version\\\":3,\\\"kind\\\":2}\", ExtendedPropertyType.Json);\nfieldColumn.IsHidden = true;\norderColumn.IsHidden = true;\n",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    },
    {
      "Id": 20,
      "Name": "Format\\Percent x.xx%",
      "Enabled": "true",
      "Execute": "foreach(var c in Selected.Columns) {\n    c.FormatString = \"#,##0.00 %;(#,##0.00 %)\"; //9.99%\n}\n\nforeach(var m in Selected.Measures) {\n    m.FormatString = \"#,##0.00 %;(#,##0.00 %)\"; //9.99%\n}",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    },
    {
      "Id": 21,
      "Name": "Format\\Percent x.x%",
      "Enabled": "true",
      "Execute": "foreach(var c in Selected.Columns) {\n    c.FormatString = \"#,##0.0 %;(#,##0.0 %)\"; //9.9%\n}\n\nforeach(var m in Selected.Measures) {\n    m.FormatString = \"#,##0.0 %;(#,##0.0 %)\"; //9.9%\n}",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    },
    {
      "Id": 22,
      "Name": "Format\\Percent x%",
      "Enabled": "true",
      "Execute": "foreach(var c in Selected.Columns) {\n    c.FormatString = \"#,##0 %;(#,##0 %)\"; //9.9%\n}\n\nforeach(var m in Selected.Measures) {\n    m.FormatString = \"#,##0 %;(#,##0 %)\"; //9.9%\n}",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    },
    {
      "Id": 23,
      "Name": "Format\\Currency $x,xxx.xx",
      "Enabled": "true",
      "Execute": "foreach(var c in Selected.Columns) {\n    c.FormatString = \"$ #,##0.00;($ #,##0.00)\"; //$9.99\n}\n\nforeach(var m in Selected.Measures) {\n    m.FormatString = \"$ #,##0.00;($ #,##0.00)\"; //$9.99\n}",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    },
    {
      "Id": 24,
      "Name": "Format\\Currency $x,xxx.x",
      "Enabled": "true",
      "Execute": "foreach(var c in Selected.Columns) {\n    c.FormatString = \"$ #,##0.0;($ #,##0.0)\"; //$9.99\n}\n\nforeach(var m in Selected.Measures) {\n    m.FormatString = \"$ #,##0.0;($ #,##0.0)\"; //$9.99\n}",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    },
    {
      "Id": 25,
      "Name": "Format\\Currency $x,xxx",
      "Enabled": "true",
      "Execute": "foreach(var c in Selected.Columns) {\n    c.FormatString = \"$ #,##0;($ #,##0)\"; //$9.99\n}\n\nforeach(var m in Selected.Measures) {\n    m.FormatString = \"$ #,##0;($ #,##0)\"; //$9.99\n}",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    },
    {
      "Id": 26,
      "Name": "Format\\Integer",
      "Enabled": "true",
      "Execute": "foreach(var c in Selected.Columns) {\n    c.FormatString = \"#,##0;(#,##0)\";\n}\n\nforeach(var m in Selected.Measures) {\n    m.FormatString = \"#,##0;(#,##0)\";\n}",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    },
    {
      "Id": 27,
      "Name": "Format\\Decimal x.xx",
      "Enabled": "true",
      "Execute": "foreach(var c in Selected.Columns) {\n    c.FormatString = \"#,##0.00;(#,##0.00)\";\n}\n\nforeach(var m in Selected.Measures) {\n    m.FormatString = \"#,##0.00;(#,##0.00)\";\n}",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    },
    {
      "Id": 28,
      "Name": "Format\\Decimal x.x",
      "Enabled": "true",
      "Execute": "foreach(var c in Selected.Columns) {\n    c.FormatString = \"#,##0.0;(#,##0.0)\";\n}\n\nforeach(var m in Selected.Measures) {\n    m.FormatString = \"#,##0.0;(#,##0.0)\";\n}",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    },
    {
      "Id": 29,
      "Name": "Format\\String",
      "Enabled": "true",
      "Execute": "foreach(var c in Selected.Columns) {\n    c.FormatString = \"Text\";\n}\n\nforeach(var m in Selected.Measures) {\n    m.FormatString = \"Text\";\n}",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    },
    {
      "Id": 30,
      "Name": "Format\\Datetime 3/14/2023",
      "Enabled": "true",
      "Execute": "foreach(var c in Selected.Columns) {\n    c.FormatString = \"m/d/yyyy\";\n}\n\nforeach(var m in Selected.Measures) {\n    m.FormatString = \"m/d/yyyy\";\n}",
      "Tooltip": "",
      "ValidContexts": "Measure, Column"
    }
  ]
}
otykier commented 3 months ago

@hayescode thanks for sharing your file.

It turns out we have a bug where the macro loading stops if the macros are not specified in a sequential order in the file. In your example, the macros with IDs 4 and 5 are out of order. If you rearrange them in the file, then everything should work as expected.

We will make sure this is fixed in a future update, as the order of macro IDs in the file should not matter.

hayescode commented 2 months ago

@otykier ah thank you very much!

otykier commented 3 weeks ago

This is now fixed in 3.15.0. Thanks a lot for reporting the issue!