Accounting Analytics: An Integrated Approach
Part IV of V: Data Visualization and Power BI
Chapter 2 of 4 in this Part
Table 14.1 · Fact tables of the Charles River reports, with their grain and dimensions
| Fact table | Grain: one row for each | Dimensions | Chapter |
|---|---|---|---|
| SalesInvoiceLine | line of an invoice | Item, Customer, Date | 13, 14 |
| GLEntry | posting to an account | Account, CostCenter, Date | 14 |
| BudgetLine | month, account, cost center, and item | Account, CostCenter, Date | 15 |
| LaborTimeEntry | time entry of an employee | Employee, WorkCenter, Date | 15 |
| ProductionCompletionLine | item line of a completion | Item, Date | 15 |
| JournalEntry, PurchaseOrder, PayrollRegister | document tested for exceptions | Employee, Date | 16 |
| Exceptions | exception of one test on one document | Tests, Employee, Date | 16 |
Which setting does each need?
Before you write measures on the new model, confirm the following:
Standard Cost =
SUMX (
SalesInvoiceLine,
SalesInvoiceLine[Quantity]
* RELATED ( 'Item'[StandardCost] )
)
Which context applies, and what is the result?
Furniture Revenue =
CALCULATE ( [Revenue], 'Item'[ItemGroup] = "Furniture" )
Share of Revenue =
DIVIDE (
[Revenue],
CALCULATE ( [Revenue], REMOVEFILTERS ( 'Item' ) )
)
Table 14.3 · DAX functions used in this chapter
| Function | What it does | Example in this chapter |
|---|---|---|
SUM |
Adds up a column over the rows in the filter context | Revenue |
DISTINCTCOUNT |
Counts the different values of a column | Invoices |
DIVIDE |
Divides, returning a blank when the denominator is zero | Margin % |
SUMX |
Evaluates an expression row by row and adds the results | Standard Cost |
RELATED |
Returns a value from the one side of a relationship | Standard Cost |
Table 14.3 · DAX functions used in this chapter
| Function | What it does | Example in this chapter |
|---|---|---|
CALCULATE |
Evaluates an expression in a modified filter context | Furniture Revenue |
REMOVEFILTERS |
Removes filters from a table or column inside CALCULATE | Share of Revenue |
USERELATIONSHIP |
Activates an inactive relationship inside CALCULATE | Revenue by ship date |
VAR, RETURN |
Name an intermediate result and use it | Margin % |
Gross Margin = [Revenue] - [Standard Cost]
Margin % =
VAR Rev = [Revenue]
RETURN
DIVIDE ( Rev - [Standard Cost], Rev )
Discount Rate =
DIVIDE ( [Discounts], [Price Before Discount] )
Your model should now pass these checks:
Table 14.4 · Time intelligence functions of this Part and where they are used
| Function | Returns, for the dates in the filter context | Used in |
|---|---|---|
TOTALYTD |
A measure’s total for the year to date, from January 1 unless another year-end is given | Revenue YTD, Exercise 14.3 |
SAMEPERIODLASTYEAR |
The same dates one year earlier | Revenue PY, Exercise 14.3 |
DATEADD |
The dates shifted by a number of days, months, quarters, or years | The prior quarter, Exercise 14.4 |
DATESBETWEEN |
The dates between two dates, inclusive | The three months before, Tutorial 14.3 |
DATESINPERIOD |
A period of a given length ending on a date | The trailing twelve months, Chapter 15 |
CALCULATE ( [Revenue], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )Which function does each comparison need?
GL Amount =
CALCULATE (
SUM ( GLEntry[Debit] ) - SUM ( GLEntry[Credit] ),
GLEntry[IsYearEndClose] = FALSE ()
)
P&L Amount = - [GL Amount]
What went wrong in each report?
Before you build reports on the model, confirm the following:
Calculated column · Context transition · Cross filter direction · DAX · DAX query view · Date table · Degenerate dimension · Dimension table · Fact table · Filter context · Grain · Inactive relationship · Iterator · Measure · Row context · Snowflake schema · Star schema · Time intelligence
Next: Chapter 15: Reports for Management Decisions
These slides accompany Accounting Analytics: An Integrated Approach, licensed under CC BY-SA 4.0. Every figure and table comes from the chapter:
https://aa.accountinganalyticshub.com/chapters/14-data-models-and-dax/chapter.html
Chapter 14 · Data Models and DAX Measures