power query vs Dax
Darshika Srivastava
Associate Project Manager @ HuQuo | MBA,Amity Business School
What is Power Query M?
Unlike other business intelligence tools, Power BI includes its own data engineering tool. As a result, the advanced business user can even build his own little data warehouse.
Some users are already familiar with Power Query through Excel or other Microsoft tools (e.B. Power Apps, Azure Data Factory, SQL Server Analysis Services, or Dynamics 365 Customer Insights).?Of course, if that's you, you'll have a head start.
First and foremost, Power Query is an Extract Transform Load (ETL) tool. It allows us to
With its well-arranged graphical user interface, similar to the environment of other Microsoft tools, even you as a beginner will soon be able to perform complex cleanup and formatting transformations, often without having to touch a line of code.
Once you and Power Query have gotten a little closer, you can - by mutual agreement - become more intimate: explore M's dirty little secrets, and you will discover an adult functional programming language.
As convenient as the point-and-click in Power Query is, M opens even more doors, with even more possibilities. One point I really like about Power Query and M is that I can switch between no-code and coding whenever I want.
DAX
DAX, or Data Analysis Expressions, is another programming language in Power BI. It is very different from M and has a completely different use case. DAX is most similar to Microsoft Excel functions. Technically, DAX is not a complete programming language, but a collection of functions and operators.
Users with programming skills find it easier to get started in M than in DAX. The most difficult hurdle at the beginning is to understand that each DAX measure can - and will - refer to different data contexts in the analytical data model. Desperate exclamations in our office are the order of the day: "But what does this thing do? If only I could debug that!"??
Currently, more than 250 functions are in use in DAX and the number continues to rise. For an overview, see the Microsoft documentation page.
DAX functions include filters, aggregations, financial functions, mathematical and logical functions, data relationship functions, time and date intelligence, and many more.??
You can use DAX functions to create measures and calculated columns.?Measures are dynamic calculation formulas in which the results change depending on the context. Contrarily to calculated columns, measures do not calculate values for each row. Instead, they return aggregated values from a set of rows (called context). They are extremely useful for data visualization and data analysis.??
My recommendation for the beginner: Whenever possible, use the Quick Measure functions, which provide a point-and-click definition of commonly used DAX operations such as sum, mininum, maximum, etc. Quickmeasures in Power BI are irreplaceable both as reference and learning tool, but as well as a starting point for more complex measures.
And while we're at it, here's another recommendation: By all means learn DAX Studio as early as possible. It is a truly irreplaceable tool!
When do I use M, and when do I use DAX?
In computer science, just as in many other fields, the following axiom usually applies: Many paths lead to Rome. In Power BI, this is especially true. The difficulty is to learn when it is best to use one tool over the other. ?
领英推荐
For example, you can do a calculation, an aggregation, as well as filtering in both M (i.e. in data engineering) and in DAX (i.e. in data analysis).
At Power Partners, we defined clear rules regarding the usage of DAX and M. This makes easier for new employees to get started, and it simplifies communication among the team members.
Power Query
Power Query / M is used for data engineering, so:
The following rules apply:
Exceptions confirm the rule. For example, there are situations where a calculation in M is much easier to accomplish. Or, sometimes we are facing huge amounts of data, such that aggregation in M saves us a fair amount of trouble down the road.
DAX
DAX is used for data analysis, so:
A blueprint for a Power BI data process
Our first steps are always done in the Power Query Editor, where we collect data from different sources, clean and format the data.
DAX only comes into play in the second step, in data analysis. We primarily calculate measures and KPIs, and and use DAX to filter for the visualization at hand.
Conclusion
In summary, we always start in the Power Query editor. With the graphical user interface and M language, beginners and advanced users can prepare the data for further analysis and visualization.
DAX, on the other hand, is used in a second stage, to make calculations from several records, and to aggregate facts individually.