0% found this document useful (0 votes)
3 views2 pages

DAX Formulas

The document outlines various DAX (Data Analysis Expressions) functions used to manipulate and extract information from an Orders dataset. It includes methods for extracting date components, string manipulations, conditional evaluations, and aggregate calculations. Additionally, it describes the creation of a date table and calendar functions for enhanced data analysis.

Uploaded by

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

DAX Formulas

The document outlines various DAX (Data Analysis Expressions) functions used to manipulate and extract information from an Orders dataset. It includes methods for extracting date components, string manipulations, conditional evaluations, and aggregate calculations. Additionally, it describes the creation of a date table and calendar functions for enhanced data analysis.

Uploaded by

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

-- Extract Day

Orders_Day = DAY(Orders[Order Date])

-- Extract Time
Orders[Time] = TIME(HOUR(Orders[Order Date]), MINUTE(Orders[Order Date]),
SECOND(Orders[Order Date]))

-- Extract Month
Orders[Month] = MONTH(Orders[Order Date])

-- Extract Year
Orders[Year] = YEAR(Orders[Order Date])

-- Extract Weekday (0=Sunday, 1=Monday, ..., 6=Saturday)


Orders[Weekday] = WEEKDAY(Orders[Order Date])

-- Extract Month Name


Orders[MonthName] = FORMAT(Orders[Order Date], "MMMM")

-- Date Table
DateTable = CALENDAR(MIN(Orders[Order Date]), MAX(Orders[Order Date]))

-- Calendar Function
Calendar = ADDCOLUMNS(DateTable, "Year", YEAR([Date]), "Month", MONTH([Date]),
"Day", DAY([Date]), "Weekday", WEEKDAY([Date]), "MonthName", FORMAT([Date],
"MMMM"))

-- Auto Calendar Function (with additional columns)


AutoCalendar =
ADDCOLUMNS(
CALENDAR(MIN(Orders[Order Date]), MAX(Orders[Order Date])),
"Year", YEAR([Date]),
"Month", MONTH([Date]),
"MonthName", FORMAT([Date], "MMMM"),
"Quarter", QUARTER([Date]),
"Day", DAY([Date]),
"Weekday", WEEKDAY([Date]),
"WeekOfYear", WEEKNUM([Date], 2),
"DayOfYear", DAY([Date]) - DATE(YEAR([Date]),1,1) + 1
)

-- Concatenate
Orders[Concatenate] = Orders[Customer Name]

-- Left (extract first n characters)


Orders[Left] = LEFT(Orders[Customer Name], 5) -- Change 5 to the desired number of
characters

-- Right (extract last n characters)


Orders[Right] = RIGHT(Orders[Customer Name], 5) -- Change 5 to the desired number
of characters

-- Mid (extract characters from a specified position)


Orders[Mid] = MID(Orders[Customer Name], 3, 5) -- Starting at position 3, extract 5
characters

-- Len (length of the string)


Orders[Len] = LEN(Orders[Customer Name])
-- Lower (convert to lowercase)
Orders[Lower] = LOWER(Orders[Customer Name])

-- Upper (convert to uppercase)


Orders[Upper] = UPPER(Orders[Customer Name])

-- Trim (remove leading and trailing spaces)


Orders[Trim] = TRIM(Orders[Customer Name])

-- IF condition
Orders[IF_Result] = IF(Orders[Sales] > 1000, "High", "Low")

-- AND condition
Orders[AND_Result] = IF(AND(Orders[Sales] > 1000, Orders[Quantity] > 5), "Both
conditions met", "At least one condition not met")

-- OR condition
Orders[OR_Result] = IF(OR(Orders[Sales] > 1000, Orders[Quantity] > 5), "At least
one condition met", "Both conditions not met")

-- SWITCH function
Orders[Switch_Result] = SWITCH(TRUE(), Orders[Sales] > 2000, "High", Orders[Sales]
> 1000, "Medium", "Low")

-- IFERROR function
Orders[IFERROR_Result] = IFERROR(1 / Orders[Quantity], "Error")

-- SUM function
Orders[Sum_Result] = SUM(Orders[Sales])

-- MIN function
Orders[Min_Result] = MIN(Orders[Sales])

-- MAX function
Orders[Max_Result] = MAX(Orders[Sales])

-- AVERAGE function
Orders[Average_Result] = AVERAGE(Orders[Sales])

-- COUNT function
Orders[Count_Result] = COUNT(Orders[Order ID])

-- CALCULATE function
Orders[Calculate_Result] = CALCULATE(SUM(Orders[Sales]), Orders[Category] =
"Technology")

-- ALL function
Orders[All_Result] = CALCULATE(SUM(Orders[Sales]), ALL(Orders))

-- ALLEXCEPT function
Orders[Allexcept_Result] = CALCULATE(SUM(Orders[Sales]), ALLEXCEPT(Orders,
Orders[Category]))

-- KEEPFILTERS function
Orders[Keepfilters_Result] = CALCULATE(SUM(Orders[Sales]), KEEPFILTERS(Orders))

You might also like