The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Dear all,
I thought I would share some recent work I have completed. I have quite a large dashboard project involving space usage analysis at a large University, drawing from data sources such as the timetabling system, automatic people counting monitors and computing logons in various teach labs.
This project requires ongoing modifications as new data sources are brought in, improvements are made to the systems that provide data feeds, or issues are discovered that need to be corrected.
A large challenge is that when I make changes to the data model how do I validate that these changes have not introduced any issues. To this end I am trying to adopt a robust Testing framework for my developments.
What I have done is build a Power Query test bench to test the output of a given query against the existing version in production (which I assume is the "truth"), one could also use a test input dataset to a query and compare the output against a test output.
Given that M is a functional language (and mostly pure - so there are no side effects) I can be sure that if any changes are made to a query and it produces the correct outputs and no other changes have been made anywhere else in the data model then the over-all new data model is "correct" given the modifications.
I run the tests against tables, but I also have tests for lists to identify where an error may be if a table fails the tests.
Here is the test bench I have written
https://github.com/robertsbd/M/blob/master/testBench
This is what the output for a single table looks like, with table names and col names made up
Testing tables: (17/05/2017 21:00:51)
TABLE A = my_table1
TABLE B = my_table2
Equality test (table equality): PASSED.
Length test (RowNum equality): PASSED. Number of rows TABLE A=625 TABLE B=625
Column number test (ColNum equality): PASSED. Number of cols TABLE A=8 TABLE B=8
Column name test (ColName equality): PASSED. Names of rows TABLE A= {name1, name2, name3, name4, name5, name6, name7, name8} TABLE B= {name1, name2, name3, name4, name5, name6, name7, name8}
User | Count |
---|---|
65 | |
61 | |
60 | |
53 | |
30 |
User | Count |
---|---|
180 | |
88 | |
71 | |
48 | |
46 |