Data Analysis Expressions (DAX) Interview Questions
1. Explain What Is Dax?
DAX stands for Data Analysis Expressions, and it is the formula language simply it is a collection of functions, operators, and constants that can be used in a formula, or expression in Microsoft SQL Server Analysis Services, Power Pivot in Excel, and Power BI Desktop. Stated more simply, DAX helps you create new information from data already in your model.expressions.
2. Explain When Do You Use Sumx() Instead Of Sum()?
When the expressions to SUM() consits of anything else than a column name.
Typically when you want to add or multiply the values in different columns:
SUMX(Orderline, Orderline[quantity], Orderline[price])
SUMX() first creates a row context over the Sales table (see 1 above). It then iterates through this table one row at a time. SUM() is optimized for reducing over column segments and is as such not an iterator.
3. What Do You Understand By New Calendarauto() Function In Dax(ssas)?
CALENDARAUTO function returns a table with a single column named “Date” that contains a contiguous set of dates. The range of dates is calculated automatically based on data in the model.
Example:
In this example, the MinDate and MaxDate in the data model are July 1, 2010 and June 30, 2011.
CALENDARAUTO() will return all dates between January 1, 2010 and December 31, 2011.
CALENDARAUTO(3) will actually return all dates between April 1, 2010 and March 31, 2012.
4. Name Any 3 Most Useful Aggregation Functions Dax?
DAX has a number of aggregation functions, including the following commonly used functions:
- SUM
- AVERAGE
- MIN
- MAX
- SUMX (and other X functions)
These functions work only on numeric columns, and generally can aggregate only one column at a time. However, special aggregation functions that end in X, such as SUMX, can work on multiple columns. These functions iterate through the table, and evaluate the expression for each row.
5. Which Are The Three Places Where An Expression Can Be Evaluated And Hence A Specific Context Is Set?
-
- In a pivot table cell. Filter context is set by rows, columns, filters and slicers.
- In a row cell (calculated column) Row context is set by the row itself.
- In the measure calculation area of a table. No row, nor filter context is set.
6. Name Any 3 Most Useful Text Functions In Dax?
The text functions in DAX include the following:
- CONCATENTATE
- REPLACE
- SEARCH
- UPPER
- FIXED
These text work very similarly to the Excel functions that have the same name, so if you’re familiar with how Excel handles text functions, you’re already a step ahead. If not, you can always experiment with these functions in Power BI, and learn more about how they behave.
7. How Is Filter Context Propagated Through Relationships?
Filter context automatically propagates following the filtering of the relationship. It always propagates from the one side of the relationship to the many side. In addition, you also have the option of enabling the propagation from the many side to the one side. No functions are available to force the propagation: Everything happens inside the engine in an automatic way, according to the definition of relationships in the data model.
8. What Is The Difference Between Distinct() And Values() In Dax?
Both count the distinct values, but VALUES() also counts a possible implictit virtual empty row because of non matching values in a child table. This is usually in a dimension table.
9. Which Function Should You Use Rather Than Countrouws(distinct())?
DISTINCTCOUNT()
10. What Is A Pattern?
A pattern is a general reusable solution to a commonly occurring problem.In Microsoft Excel, you use patterns every day to build tables, charts, reports, dashboards, and more.
11. What Are Dax Patterns?
DAX Patterns is a collection of ready-to-use data models and formulas in DAX, which is the programming language of Power Pivot. Create your Excel data model faster by using a DAX pattern
12. Explain Related() And Relatedtable()?
RELATED works when you have a row context on the table on the many side of a relationship. RELATEDTABLE works if the row context is active on the one side of a relationship. It is worth noting that both, RELATED and RELATEDTABLE, can traverse a long chain of relationships to gather their result; they are not limited to a single hop.
13. Explain How A Pivot Table Can Be Viewd As An Mvc System?
- Model = the Data Model (incl DAX expressions)
- View = the table (or chart)
- Controller = rows + columns + filters + slicers
What can you say about automatic filter propagation The filters only ever automatically flow from the “one” side of the relationship to the “many” side of the relationship; from the “arrow” side to the “dot” side; from the lookup table to the data table—whatever terms you use, it’s always downhill.
With the lookup tables above and the data tables below, it is a mental cue to help you instantly visualize how automatic filter propagation works.
14. How Does Calculate() Result In Context Transition?
When in row context it transitions to filter context: the filter on the rows of a specific table propagates through the relationship to the related before the calculation is completed.
E.g
. CALCULATE(SUM(OtherTable[column]) in a calculated column.
It extends or modifies an existing filter context, by adding a filter as its second parameter.
CALCULATE() always introduces filter context.
15. What Is The Difference Between Max And Maxa Functions In Dax?
The MAX function takes as an argument a column that contains numeric values. If the column contains no numbers, MAX returns a blank. If you want to evaluate values that are not numbers, use the MAXA function.
16. How Are Row Contexts Created?
-
- Automatically in a calculated column
- Programmatically by using iterators.
17. How Are Filter Contexts Created?
-
- Automatically by using fields on rows, columns, slicers, and filters.
- Programmatically by using CALCULATE()
18. How Can You Propagate Row Context Through Relationships?
Propagation happens manually by using RELATED() and RELATEDTABLE(). These functions need to be used on the correct side of a one-to-many relationship: RELATED() on the many side, RELATEDTABLE() on the one side.
19. How Does Summarizecolumns Relate To Filtering?
-
- SUMMARIZECOLUMNS is not susceptible for outer (external) filters, in contrast to SUMMARIZE
- you can add a filter (e.g. using FILTER) as a param of SUMMARIZCOLUMNS and it will filter accordingly. It acts as if you’ve added a filter in a pivot table.
20. What Is The Initial Filter Context?
The initial filter context comes from four areas of a pivot table:
- Rows
- Columns
- Filters
- Slicers
It is the standard filtering coming from a pivot table before any possible modifications from DAX formulas using CALCULATE().
21. Why Don’t You Use A Calculate() In The Aggregation Expression Of A Summarizecolumn()?
The CALCULATE() is automatically generated.
22. What Is The Difference Between Having A Measure As A Second Filter Param And Having The Original Measure Expression As A Param. Filter(table, [measure]) Vs Filter(table, Sum(…))?
A measure has always implicit filter context, so the ROW context induced by the FILTER is transferred to filter context in the measure.
In case of the expression only, no filter context is imposed on the expression, so the expression is evaluated with an empty filter context! This gives a different result.
23. Dax Nested Functions Is Equivalent To Sql What?
SQL subqueries.