0% found this document useful (0 votes)
6 views

Contoso DAX Formulas

Uploaded by

johnmwaugh69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Contoso DAX Formulas

Uploaded by

johnmwaugh69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

SumOfSales = SUMX(Sales, Sales[Quantity] * Sales[Net Price])

SumOfSingleSales = SUMX(
FILTER(
Sales,
Sales[Quantity] = 1
),
Sales[Net Price]
)

SumOfMultipleSales = SUMX(
FILTER(
Sales,
Sales[Quantity] > 1
),
Sales[Quantity] * Sales[Net Price]
)

MultipleUnitsSold = SUMX(
FILTER(Sales, Sales[Quantity] > 1), Sales[Quantity])

CountOfSingleSales = COUNTX(
FILTER(Sales, Sales[Quantity] = 1), Sales[Quantity])

CountOfMultipleSales = COUNTX(
FILTER(Sales, Sales[Quantity] > 1), Sales[Quantity])

TotalNumberOfSales = COUNTROWS(RELATEDTABLE(Sales))

TotalQuantitySold = SUMX(Sales, Sales[Quantity])

SumOfSalesUnitPrice = SUMX(Sales, Sales[Quantity] * RELATED( Product[Unit Price] ))

*Note Sales Table is Related to Product Table on ProductKey column.

Sales Pct :=
DIVIDE (
SUMX ( Sales, Sales[Quantity] * Sales[Net Price] ),
SUMX ( ALL ( Sales ), Sales[Quantity] * Sales[Net Price] )
)

Sales Pct Select :=


DIVIDE (
SUMX ( Sales, Sales[Quantity] * Sales[Net Price] ),
SUMX ( ALLSELECTED ( Sales ), Sales[Quantity] * Sales[Net Price] )
)
Adjusted Cost =
IF(
RELATED('Product Category'[Category]) = "Cell phones",
Sales[Unit Cost] * 0.95,
Sales[Unit Cost]
)

BestCategories =
VAR Subcategories =
ALL ( 'Product'[Category], 'Product'[Subcategory] )
VAR AverageSales =
AVERAGEX (
Subcategories,
SUMX ( RELATEDTABLE ( Sales ), Sales[Quantity] * Sales[Net Price] )
)
VAR TopCategories =
FILTER (
Subcategories,
VAR SalesOfCategory =
SUMX ( RELATEDTABLE ( Sales ), Sales[Quantity] * Sales[Net Price] )
RETURN
SalesOfCategory >= AverageSales * 2
)
RETURN
TopCategories

Measures to deal with multiple Fact tables:

Correct Average :=
AVERAGEX(
SUMMARIZE (
Sales,
Sales[CustomerKey],
Sales[YearlyIncome]
),
)

CALCULATE(
[Sales Amount],
USERELATIONSHIP(Sales[DeliveryDateKey], ‘Date’[DateKey])
)

Allows computation of Sales Amount on Delivery Date as well as Order Date where there is an
inactive realtionship between Sales[DeliveryDateKey] and Date[DateKey]

You might also like