top of page

Data Refresh in Tabular Editor

  • MK
  • Mar 17, 2021
  • 3 min read

Updated: Jun 21, 2022

***The scripts shown in this post have been updated to work in both Tabular Editor 2.x & Tabular Editor 3.


Tabular Editor offers so many inherent features which make it such an invaluable tool for developing tabular models. However, what makes it even better is the ability to write custom C# code using the Advanced Scripting window. This creates a plethora of possibilities only limited by the imagination. Many of my recent posts take advantage of this feature and this post is no exception.


As with all nifty advanced scripts, I recommend saving these scripts as Custom Actions so you can have easy access to them at any time.


Processing multiple tables


It has previously been shown how to refresh a table within Tabular Editor but we can take it a step further. The script below is able to process multiple tables - not just a single table. Naturally, it can also process a single table. Here's how it works:


Note: This requires Tabular Editor version 2.12.1 or higher and that you are connected live to an Analysis Services instance (File->Open->From DB...). This can also be a Power BI Premium dataset or if Tabular Editor is opened using the Power BI Desktop 'External Tools' option.


  1. Within Tabular Editor, select the tables you want to process within the Table List.



2. Copy and paste the code below into the Advanced Scripting window (save it as a Custom Action).


#r "Microsoft.AnalysisServices.Core.dll"
using ToM = Microsoft.AnalysisServices.Tabular;

var refreshType = ToM.RefreshType.DataOnly;
ToM.SaveOptions so = new ToM.SaveOptions();
//so.MaxParallelism = 10;

foreach (var t in Selected.Tables)
{
    string tableName = t.Name;
    Model.Database.TOMDatabase.Model.Tables[tableName].RequestRefresh(refreshType); 
}

Model.Database.TOMDatabase.Model.SaveChanges(so);

3. Update the refreshType parameter according to how you would like to process the tables. The options are documented here.


4. If you want to use the Sequence command to specify the Max Parallelism option, simply uncomment the 'so.MaxParallelism' line and specify the desired MaxParallelism value.


5. Click the play button (or press F5) to start the data refresh.


Processing multiple partitions


The only difference in processing partitions is that you select partitions. Otherwise, the instructions are the same as for processing tables. Just use the code below.


#r "Microsoft.AnalysisServices.Core.dll"
using ToM = Microsoft.AnalysisServices.Tabular;

var refreshType = ToM.RefreshType.DataOnly;
ToM.SaveOptions so = new ToM.SaveOptions();
//so.MaxParallelism = 10;

foreach (var p in Selected.Partitions)
{
    string tableName = p.Table.Name;
    string partitionName = p.Name;
    Model.Database.TOMDatabase.Model.Tables[tableName].Partitions[partitionName].RequestRefresh(refreshType); 
}

Model.Database.TOMDatabase.Model.SaveChanges(so);

Processing the model


Processing the whole model is not recommended. However, recalculating the model is fine. Just these 4 lines of code are needed to do the job. Simply paste this code into the Advanced Scripting window and click play.


#r "Microsoft.AnalysisServices.Core.dll"
using ToM = Microsoft.AnalysisServices.Tabular;

var refreshType = ToM.RefreshType.Calculate;
Model.Database.TOMDatabase.Model.RequestRefresh(refreshType); 
Model.Database.TOMDatabase.Model.SaveChanges();

additional context


These scripts directly access the Tabular Object Model and actually do not generate TMSL (to which many of us are accustomed). The scripts (well, the RequestRefresh method) generate XML. TMSL is much cleaner and easier to read which is why it is used when scripting out code in this context. However, the TMSL gets translated into XML by the engine. Therefore, the scripts used in this post skip the TMSL part and feed XML directly to the server (since the engine does not care about code beautification). You can run a SQL Server profiler trace and see this for yourself. Actually, when you run TMSL you will also see the XML command (translated from TMSL) in the profiler trace. When you run a profiler trace against the scripts in this post you will only see the XML command.


Conclusion


It should be noted that processing large datasets within Tabular Editor is not recommended. This method is best for quickly processing relatively smaller datasets. Not to worry, I have a new tool coming out soon which offers a more robust solution for more complex processing scenarios. Stay tuned!

211 Comments


khi tôi tiếp tục quan sát hệ thống SHBET , tôi thấy cách tổ chức nội dung được xây dựng theo hướng rõ ràng và dễ hiểu. các khu vực được phân chia hợp lý giúp người dùng dễ dàng định hướng khi truy cập. trong quá trình sử dụng, tốc độ phản hồi khá ổn định và thao tác giữa các chuyên mục diễn ra tương đối nhanh. giao diện cũng được tối ưu tốt trên cả điện thoại và máy tính giúp trải nghiệm không bị thay đổi nhiều. điều này giúp người dùng tiếp cận thông tin thuận tiện hơn và sử dụng hiệu quả hơn trong thực tế

Like

У інверторах і системах накопичення Huawei одна й та сама зовнішня ознака може мати кілька причин, тому код на дисплеї варто розглядати як окреме джерело інформації. Перед будь-якими діями корисно переглянути https://topmaster.com.ua/pomylky/huawei/ та зрозуміти, чи відповідає розшифровка тому, як поводиться конкретний пристрій.


Особливо важливо зафіксувати момент появи збою: одразу після запуску, під навантаженням, після нагріву, під час зміни режиму чи вже після тривалої роботи. Така послідовність часто звужує коло причин сильніше, ніж сам код. Корисно одночасно записати напругу батареї, стан мережі, навантаження та PV, якщо вони є. Для енергетичних систем ці параметри часто критичні для правильного трактування. Не варто змінювати сервісні пороги лише для того, щоб прибрати повідомлення. Якщо код повторюється при нормальних показниках, краще перевірити журнал подій і схему…

Like

Trong một lần mình đánh giá luck8 sau nhiều phiên truy cập liên tiếp, mình nhận thấy bố cục tổng thể vẫn giữ được sự thống nhất ở cách hiển thị các chuyên mục. Các khu vực như thể thao, casino và nổ hũ được phân chia hợp lý nên việc xác định nội dung cần xem diễn ra nhanh hơn. Mình thấy giao diện được xây dựng theo hướng trực quan, giúp người dùng dễ theo dõi khi chuyển qua nhiều danh mục. Trong lúc trải nghiệm mình thử thể thao và nổ hũ thì hệ thống phản hồi ổn định, tốc độ tải đều và thao tác điều hướng diễn ra khá mượt

Like

Коли маркування AEROPOSTALE незнайоме, я б не переводив його по пам’яті. Простіше одразу перейти до https://zastibka.com.ua/brendy/aeropostale/, знайти свій діапазон у сантиметрах і вже від нього визначити потрібну цифру або літеру.


Для повсякденного молодіжного одягу корисно врахувати таку деталь: для джинсів окремо дивитися талію та довжину, а для футболок і худі — груди й бажану свободу. Повторний замір часто рятує від помилки. Один сантиметр легко з’являється через перекошену стрічку, неправильну точку або надто сильний натяг. Якщо цифра виглядає несподівано, замір краще повторити.


Застібка в цьому випадку працює як звичайний довідник відповідностей. Після таблиці все одно варто подивитися опис конкретної моделі, склад і задуману посадку. Це дає більше користі, ніж універсальні поради на кшталт «брати на розмір більше». Для AEROPOSTALE також варто…

Like

bing leo
bing leo
Aug 14

This is a great breakdown of Tabular Editor's scripting capabilities for data refresh. I particularly appreciate the emphasis on how C# scripting unlocks "a plethora of possibilities." Have you found specific performance gains when processing multiple tables versus individual ones using these scripts? discord id look up

Like

©2021 by Elegant BI

bottom of page