Excel catalyst 48th wave of open source and PowerBIDeskTop interconnection of -Excel The second

The previous sharing, the main technology comes to the Excel PivotTable connection PowerBIDeskTop, during a visit SSAS model, not only can use a pivot table access, but can send data model launched DAX or MDX query returns a result table data, PivotTable way than the more flexible.
Cipian again bring out Excel issued technical points DAX queries to PowerBIDeskTop.

Cipian corresponding functions implemented by: Wave 5 - Use DAX query to obtain data from the source https://www.jianshu.com/p/21b2ca8fd2b8 in PowerbiDeskTop

The theoretical analysis

And on a similar, again using OLEDB data connections, SSAS and analysis services to connect, but this time using the programming mode, the SSAS service launched OleDbCommand, the DAX query as a parameter passed to OleDbCommand, the final model will return data result.

Check code is as follows:


   public static DataTable GetDAXQueryTableFromPbid(string queryString, DataGridViewRow row)
        {
            Entity.PbidFileInfo pbidFileInfo = Common.GetPbidFileInfo(row);

            string cnnString = $"Provider=MSOLAP;Integrated Security=SSPI;Persist Security Info=True;Data Source=localhost:{pbidFileInfo.Port};Initial Catalog={pbidFileInfo.DbName};";
            using (OleDbConnection cnn = new OleDbConnection(cnnString))
            {
                cnn.Open();
                OleDbCommand cmd = new OleDbCommand(queryString, cnn);

                OleDbDataAdapter adp = new OleDbDataAdapter(cmd);
                System.Data.DataSet ds = new System.Data.DataSet();
                DataTable dt = new DataTable();
                adp.Fill(ds);
                return ds.Tables[0];
            }
        }

After initiating the above query, the data structures stored by a method of the OleDbDataAdapter Fill the DataSet, and then removed from the table DataSet debut, to get the final result.

The same code can also be used on Sqlserver SSAS service. Just need to connect the string to bring the username has permission to access the model, password.

DAX query automation

After reading the above method, already in place, here again a climax, DAX fully automated query generation.

Because PowerBIDeskTop open SSAS service is localization services, local users have full access to them, and drag the controls on PowerBIDeskTop interface is actually converted DAX query query is issued to the service for a while and return to the SSAS data structure, the rendering control after generating visualizations.

Issued its inquiry, will retain the last few queries, DMV query can use to access, so use the following code, you can get the DAX query PowerBIDeskTop issued, then the above mentioned paragraph statement OLEDB SSAS queries to the service request again, to achieve zero code written DAX query user experience.

        private void GetDAXQueryStringFromPbidAndBandingListbox()
        {
            string queryString = "select COMMAND_TEXT from $SYSTEM.DISCOVER_COMMANDS";
            DataTable dt = Common.GetDAXQueryTableFromPbid(queryString, this.dataGridView1.SelectedRows[0]);
            this.listBox1.DataSource = dt.AsEnumerable().Where(s => Regex.IsMatch(s.Field<string>(0), @"EVALUATE\s+TOPN|DEFINE\s+VAR")).Select(s => s.Field<string>(0)).ToArray();
        }

Epilogue

Excel catalyst open source, is the real thing, who are fortunate enough to see who's good fortune, the core, the most unique feature full disclosure, this is the best course of action to prove.

Technical exchange QQ group

QQ group name: Excel catalyst open discussion groups, QQ group number: 788 145 319
Excel catalyst dimensional code open source discussion groups

About Excel catalyst

Excel catalyst name, first a public micro-channel number, then shun its name, officially launched the Excel plug-in, plug-continuous updates, the update cycle depends on my time may be able to fight for one week on a line function modules. Excel catalyst plug-permanent commitment to individual users free of charge!

Excel catalyst plugin uses the latest deployment of technology, once installed, all future updates automatically update is complete, no need to repeat concerns updates, manually download the installation package to reinstall, you can always keep the latest version with a single installation!

The catalyst Excel plug-in download link: https: //pan.baidu.com/s/1Iz2_NZJ8v7C9eqhNjdnP3Q

Contact the author

No public

Named catalyst , due to strong itself, not everyone can immediately enjoy Excel, most people are still at the stage of the child's Excel software, the mind is very clear and want to achieve results, and experts who also have achieved it, that is, how to get yourself out Dounong, or worse, you do not know what Excel can do while staying in constant repetition, mechanically, manually doing data, spend countless youth years. So spawned whether as a medium, so that the majority of Excel users can instantly ignite the explosion point Excel, without the need desperately struggled day and night to learn skills, brain burn senior complex functions, going on from entry to give up the road.

最后Excel功能强大,其实还需树立一个观点,不是所有事情都要交给Excel去完成,也不是所有事情Excel都是十分胜任的,外面的世界仍然是一个广阔的世界,Excel只是其中一枚耀眼的明星,还有其他更多同样精彩强大的技术、工具等。*Excel催化剂也将借力这些其他技术,让Excel能够发挥更强大的爆发!

关于Excel催化剂作者

姓名:李伟坚,从事数据分析工作多年(BI方向),一名同样在路上的学习者。
服务过行业:零售特别是鞋服类的零售行业,电商(淘宝、天猫、京东、唯品会)

技术路线从一名普通用户,通过Excel软件的学习,从此走向数据世界,非科班IT专业人士。
历经重重难关,终于在数据的道路上达到技术平原期,学习众多的知识不再太吃力,同时也形成了自己的一套数据解决方案(数据采集、数据加工清洗、数据多维建模、数据报表展示等)。

擅长技术领域:Excel等Office家族软件、VBA&VSTO的二次开发、Sqlserver数据库技术、Sqlserver的商业智能BI技术、Powerbi技术、云服务器布署技术等等。

2018年开始职业生涯作了重大调整,从原来的正职工作,转为自由职业者,暂无固定收入,暂对前面道路不太明朗,苦重新回到正职工作,对Excel催化剂的运营和开发必定受到很大的影响(正职工作时间内不可能维护也不可能随便把工作时间内的成果公布于外,工作外的时间也十分有限,因已而立之年,家庭责任重大)。

And the majority of advocates with expectations: Excel catalyst has been able to run down, I have the benefit of the group were able to support ( multi-message encouragement, friend circle under forwarded the recommendation under small a reward and the most focused and where the company can and recommended recommended peers, so I can maximize the value of technology in your company to achieve a win-win (you can imagine how the data is preliminary consultant or small projects to develop forms of cooperation).

Guess you like

Origin www.cnblogs.com/ExcelCuiHuaJi/p/11225096.html