SlideShare a Scribd company logo
DAX
Formulas in
Power BI
SUM
FORMULA
SUM Formula in Power
BI
Definition: SUM is a simple aggregation function that adds up all
the values in a single column.
Example
Total_Sales = SUM(SalesData[Sales])
Use Case: Use SUM when you want to sum up all the values
in a numeric column without any complex row-by-row
operations.
Performance: Since it operates directly on a column, it's fast
and efficient for simple summations.
Calculated Column in Power BI
Definition: A calculated column is a new column that you create in a
table using DAX (Data Analysis Expressions). The value for each row is
calculated when the column is created, and it remains static unless
the data is refreshed.
Example
Tax = SalesData[Total_Sales]*18/100
Use Cases: Suitable for scenarios where you need a value for each
row in the table, such as adding a new field derived from existing
data (e.g., creating a "Total Price" column by multiplying "Quantity"
and "Price").
Performance: Since calculated columns are stored in the model,
Calculated Column in Power BI
Calculated Column in Power BI
DIFFERENCE BETWEEN CALCULATED COLUMN AND MEASURE IN POWER BI
In Power BI, both calculated columns and measures are used to perform calculations,
but they serve different purposes and behave differently. Here's a comparison of the two:
SUMX
FORMULA
SUMX Formula in Power
BI
Definition: SUMX is an iterator function that performs row-by-
row calculations and then sums the results.
Example
Total_Sales2 = SUMX(SalesData,SalesData[Quantity]*SalesData[Unit
Price (INR)])
Use Case: Use SUMX when you need to perform a calculation for
each row before summing, such as multiplying two columns together
or applying conditional logic.
Performance: SUMX can be slower than SUM because it performs
calculations on each row individually before summing. It's ideal for
more complex scenarios that require row context.
Difference between SUM and SUMX Formula in Power
BI
In Power BI, both SUM and SUMX are used to perform summation, but they work
differently
and are used in different scenarios. Here's a breakdown of the key differences:
COUNT
FORMULA
Count Formula in Power
BI
Definition: COUNT counts the number of non-blank values in a
column.
Example
Number of Customers = COUNT('Table'[Customer ID])
Use Case: When you want to count the non-empty values in a
column.
COUNTA
FORMULA
COUNTA Formula in Power
BI
Definition: COUNTA counts the number of non-blank values in a
column, including text, numeric values, and logical values even
counts Boolean values where only Count will not count Boolean data
type
Example
Number of Reviews = COUNTA('Table'[Review Status])
Use Case: When you need to count all non-blank values, regardless of
the
data type (text, numbers, etc.).
COUNTBLANK
FORMULA
COUNTBLANK Formula in Power BI
Definition: COUNTBLANK counts the number of blank (empty) values
in a column.
Example
Blank Reveiws = COUNTBLANK('Table'[Review Points])
Use Case: When you want to count the number of blank or missing
values
in a column.
COUNTROWS
FORMULA
COUNTROWS Formula in Power BI
Definition: COUNTROWS counts the number of rows in a
table.
Example
Total Records = COUNTROWS('Table')
Use Case: When you want to count the total number of rows in a table
or in
a filtered table.
DISTINCTCOUNT
FORMULA
DISTINCTCOUNT Formula
Definition: DISTINCTCOUNT counts the number of unique, non-blank
values in a column.
Example
Unique States = DISTINCTCOUNT('Table'[State])
Use Case: When you need to count the distinct (unique) values in
a
column, excluding blanks.
COUNTX
FORMULA
COUNTX Formula
Definition: COUNTX is an iterator function that counts non-blank
results of an expression evaluated row by row over a table.
Example
Count Reviews >= 5 = COUNTX('Table', IF('Table'[Review Points] >= 5, 1,
BLANK()))
Use Case: When you need to count based on an expression that
is
evaluated for each row in a table.
COUNTAX
FORMULA
COUNTAX Formula
Definition: COUNTAX is the iterator version of COUNTA. It evaluates
an expression for each row and counts the number of non-blank
results.
Example
Count True = COUNTAX(FILTER('Table','Table'[Review
Status]=true),'Table'[Review Status])
Use Case: When you need to count based on an expression that
is
evaluated for each row in a table even there is Binary data type.
COUNTROWS
with
FILTER
FORMULA
COUNTROWS with FILTER Formula
Definition: COUNTROWS can be used with the FILTER function to
count rows that meet specific criteria.
Example
Maharashtra Count = COUNTROWS(FILTER('Table','Table'[State]="Maharashtra"))
Use Case: When you want to count rows based on a condition or set
of
conditions.
Summary of DAX Counting Functions:
These functions provide flexibility depending on whether you're counting all rows,
distinct
values, non-blank values, or values based on expressions and conditions.
Date
Formulas
Extract
Day/Month/Year
Extract Day/Month/Year
DAY(<datetime>) : Extracts the day from a date value.
MONTH(<datetime>) : Extracts the month from a date
value. YEAR(<datetime>) : Extracts the year from a date
value.
Extract Hour/Minute/Second
Hour(<datetime>) : Extracts the Hour from a date and time value.
Minute(<datetime>) : Extracts the Minute from a date and time
value. Second(<datetime>) : Extracts the Second from a date and
time value.
Extract Hour/Minute/Second
Today() : Show Current date
Now() – Show current date and Time
Weekday() – Show Weekday in numbers between 1 to
7 Weeknum() – Show Week number in Month/Year
DatedIFF
Formula
Definition: Returns the difference between two dates in the
specified interval (days, months, years, etc.).
Syntax
DATEDIFF(<start_date>, <end_date>, <interval>)
Example
DATEDIFF(Sales[OrderDate], Sales[ShipDate], DAY)
Create
Custom
Calendar
1 . Create Custom Calendar in Power
Query
Formula
= List.Dates(#date(2023,1,1),731,#duration(1,0,0,0))
Creating a custom calendar using Power Query in Power BI is a common
and essential task when dealing with date-related data, especially for
performing time-based analysis like year-over-year (YoY), month-to-date
(MTD), and quarter-to-date (QTD) comparisons. Having a custom date
table ensures that you have control over the format, date ranges, and any
specific time-based logic needed for your reports.
2. Create Custom Calendar in Power
Query
M Code
let
// Define start and end dates for the calendar
StartDate = #date(2020, 1, 1), // You can change this to your desired start date
EndDate = Date.From(DateTime.LocalNow()), // Automatically takes today's date as the end
date
// Generate a list of dates between the start and end dates
DateList = List.Dates(StartDate, Duration.Days(EndDate - StartDate) + 1, #duration(1, 0, 0,
0)),
// Convert the list into a table
DateTable = Table.FromList(DateList, Splitter.SplitByNothing(), {"Date"}, null,
ExtraValues.Error),
// Add Year, Month, and Day columns for further analysis
AddYear = Table.AddColumn(DateTable, "Year", each Date.Year([Date]),
Int64.Type), AddMonth = Table.AddColumn(AddYear, "Month", each
Date.Month([Date]), Int64.Type), AddDay = Table.AddColumn(AddMonth, "Day",
each Date.Day([Date]), Int64.Type),
AddMonthName = Table.AddColumn(AddDay, "Month Name", each
Date.ToText([Date], "MMMM"), type text),
AddQuarter = Table.AddColumn(AddMonthName, "Quarter", each
Date.QuarterOfYear([Date]), Int64.Type),
AddYearMonth = Table.AddColumn(AddQuarter, "Year-Month", each Date.ToText([Date], "yyyy-
MM"), type text),
AddWeekOfYear = Table.AddColumn(AddYearMonth, "Week of Year", each
Date.WeekOfYear([Date]), Int64.Type),
AddDayOfWeek = Table.AddColumn(AddWeekOfYear, "Day of Week", each Date.ToText([Date],
"dddd"), type text),
3 . Calendar DAX Formula
Formula
= CALENDAR(MIN(SalesData[Date]),MAX(SalesData[Date]))
The CALENDAR DAX function in Power BI is used to generate a
continuous range of dates between a specified start and end date. It's
particularly useful when building a date table, which is essential for
time-based calculations such as year-over-year analysis, month-to-date,
quarter-to- date, etc.
4 . CalendarAuto DAX Formula
Formula
= CALENDARAUTO()
The CALENDARAUTO function in Power BI is a powerful tool for creating
a date table that automatically detects the date range from all date
columns in your data model. This means it scans your data and
generates a date range based on the minimum and maximum dates
found in the model, which is especially helpful for dynamic date tables
without specifying start or end dates manually.
MTD QTD AND YTD DAX
FORMULA
Sales MTD = TOTALMTD(SUM(Sales[SalesAmount]
),
DateTable[Date]
)
Sales QTD = TOTALQTD(SUM(Sales[SalesAmount]
),
DateTable[Date]
)
Sales YTD = TOTALYTD(SUM(Sales[SalesAmount]
),
DateTable[Date]
)
Formula
MTD (Month-to-Date), QTD (Quarter-to-Date), and YTD (Year-to-Date) are
commonly used DAX functions in Power BI for performing time-based
aggregations. They are particularly helpful for tracking progress over the
current month, quarter, or year
, making it easy to see cumulative totals
up to the present date. These functions rely on having a properly
structured date table, ideally linked to your data model.
Networkdays DAX Formula
Network Days = NETWORKDAYS("01-01-2023","31-01-
2023",1,Holidays)
Formula
In Power BI, Network Days refers to the count of working days (typically
Monday through Friday) between two specified dates, excluding
weekends and optionally excluding holidays.
Networkdays DAX Formula
Network Days = NETWORKDAYS("01-01-2023","31-01-
2023",1,Holidays)
1 or omitted: Saturday,
Sunday 2: Sunday, Monday
3: Monday, Tuesday
4: Tuesday, Wednesday
5: Wednesday, Thursday
6: Thursday, Friday
7: Friday, Saturday
11: Sunday only
12: Monday only
13: Tuesday only
14: Wednesday only
15: Thursday only
16: Friday only
17: Saturday only
DATESINPERIOD DAX FORMULA
DATESINPERIOD(<dates>, <start_date>, <number_of_intervals>,
<interval>)
Formula
The DATESINPERIOD function in DAX returns a single-column table of
dates within a specified period, based on a start date and a defined
interval. It’s useful when you need to create calculations over dynamic
date ranges (e.g., last 7 days, previous month, etc.).
DATESBETWEEN DAX FORMULA
DATESBETWEEN(<dates>, <start_date>,
<end_date>)
Formula
The DATESBETWEEN function in DAX returns a table with dates within a
specified start and end date range. This function is useful when you want
to filter data to specific date boundaries.
SAME PERIOD LAST YEAR DAX
FORMULA
SAMEPERIODLASTYEAR(<dates
>)
Formula
The SAMEPERIODLASTYEAR function in DAX is used to return a table
with the dates for the same period in the previous year
. This function is
often used in time intelligence calculations to compare current
performance to the previous year.
CALCULATE DAX
FORMULA
SAMEPERIODLASTYEAR(<dates
>)
Formula
The SAMEPERIODLASTYEAR function in DAX is used to return a table
with the dates for the same period in the previous year
. This function is
often used in time intelligence calculations to compare current
performance to the previous year.
TEXT FORMULAS
In Power BI, there are several DAX functions designed for working with
text data. These functions allow you to manipulate and format text
values in various ways. Here are some commonly used text DAX
formulas in Power BI:
LEFT
, RIGHT
, MID
LEFT("Power BI", 5) // Result:
"Power" RIGHT("Power BI", 2) //
Result: "BI" MID("Power BI", 7, 2) //
Result: "BI"
TEXT FORMULAS
In Power BI, there are several DAX functions designed for working with
text data. These functions allow you to manipulate and format text
values in various ways. Here are some commonly used text DAX
formulas in Power BI:
UPPER and LOWER
UPPER("Power BI") // Result: "POWER
BI" LOWER("Power BI") // Result:
"power bi"
LEN: Returns the length (number of characters) of a
text string.

More Related Content

PDF
PowerBI Training
PPTX
Introduction to DAX
PDF
Funções DAX.pdf
PPTX
Intro to DAX Patterns
PPTX
DAX.pptx fgrrerrerererererere rerer er eree r er
PPTX
Pass 2018 introduction to dax
PDF
knowledgeforumpowerbitrainingnew-230816140827-5eb14be7.pdf
PPTX
Introduction to DAX - Part 1
PowerBI Training
Introduction to DAX
Funções DAX.pdf
Intro to DAX Patterns
DAX.pptx fgrrerrerererererere rerer er eree r er
Pass 2018 introduction to dax
knowledgeforumpowerbitrainingnew-230816140827-5eb14be7.pdf
Introduction to DAX - Part 1

Similar to Dax formulas in power bi.pptx data analytics (20)

PPTX
Power BI data analysis power point file.
PDF
From 0 to DAX…………………………………………………………..pdf
PPTX
Power BI 2 data analysis power point file
PPTX
Power BI Session-2.pptx hehhehdhhdhdhdhhd
PDF
Dax queries.pdf
PDF
Power BI Interview Questions and Answers | Power BI Certification | Power BI ...
PDF
Microsoft Power BI Online Training.pdf
PPTX
Excel to Power BI
PPTX
DAX (Data Analysis eXpressions) from Zero to Hero
PPTX
Dax en
PPTX
Power BI DAX Kickstart
PPTX
DSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BI
PDF
Dax best practices.pdf
PPTX
Introduction-to-DAX-2017-01-12.pptx
PPTX
Getting power bi
PDF
Quick start learn dax basics in 30 minutes
PPTX
Calculated Columns and Measures in Power BI.pptx
PDF
Power Bi Courses In Pune With Placements .pdf
PPTX
Power_BI_Presentation_01_17 June'23.pptx
Power BI data analysis power point file.
From 0 to DAX…………………………………………………………..pdf
Power BI 2 data analysis power point file
Power BI Session-2.pptx hehhehdhhdhdhdhhd
Dax queries.pdf
Power BI Interview Questions and Answers | Power BI Certification | Power BI ...
Microsoft Power BI Online Training.pdf
Excel to Power BI
DAX (Data Analysis eXpressions) from Zero to Hero
Dax en
Power BI DAX Kickstart
DSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BI
Dax best practices.pdf
Introduction-to-DAX-2017-01-12.pptx
Getting power bi
Quick start learn dax basics in 30 minutes
Calculated Columns and Measures in Power BI.pptx
Power Bi Courses In Pune With Placements .pdf
Power_BI_Presentation_01_17 June'23.pptx
Ad

More from hiratayyabi123 (7)

PPT
02fundamentalsofcomputer-100219095139-phpapp01 (1).ppt
PPTX
introductiontocomputer-181230062658.pptx
PPT
fundamentalofcomputers-postaldeptt-150308230655-conversion-gate01.ppt
PPTX
introductiontocomputer-181230062658.pptx
PPTX
computer by hira anwaar tayyabi 1. pptx
PPTX
computer introduction by hira anwar 2.pptx
PPTX
computer Introduction by hira anwar 1.pptx
02fundamentalsofcomputer-100219095139-phpapp01 (1).ppt
introductiontocomputer-181230062658.pptx
fundamentalofcomputers-postaldeptt-150308230655-conversion-gate01.ppt
introductiontocomputer-181230062658.pptx
computer by hira anwaar tayyabi 1. pptx
computer introduction by hira anwar 2.pptx
computer Introduction by hira anwar 1.pptx
Ad

Recently uploaded (20)

PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Pre independence Education in Inndia.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
RMMM.pdf make it easy to upload and study
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Lesson notes of climatology university.
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Computing-Curriculum for Schools in Ghana
PDF
01-Introduction-to-Information-Management.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
master seminar digital applications in india
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Anesthesia in Laparoscopic Surgery in India
VCE English Exam - Section C Student Revision Booklet
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
Pre independence Education in Inndia.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
RMMM.pdf make it easy to upload and study
Basic Mud Logging Guide for educational purpose
Lesson notes of climatology university.
TR - Agricultural Crops Production NC III.pdf
O7-L3 Supply Chain Operations - ICLT Program
Sports Quiz easy sports quiz sports quiz
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Supply Chain Operations Speaking Notes -ICLT Program
Computing-Curriculum for Schools in Ghana
01-Introduction-to-Information-Management.pdf
PPH.pptx obstetrics and gynecology in nursing
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
master seminar digital applications in india
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Anesthesia in Laparoscopic Surgery in India

Dax formulas in power bi.pptx data analytics

  • 3. SUM Formula in Power BI Definition: SUM is a simple aggregation function that adds up all the values in a single column. Example Total_Sales = SUM(SalesData[Sales]) Use Case: Use SUM when you want to sum up all the values in a numeric column without any complex row-by-row operations. Performance: Since it operates directly on a column, it's fast and efficient for simple summations.
  • 4. Calculated Column in Power BI Definition: A calculated column is a new column that you create in a table using DAX (Data Analysis Expressions). The value for each row is calculated when the column is created, and it remains static unless the data is refreshed. Example Tax = SalesData[Total_Sales]*18/100 Use Cases: Suitable for scenarios where you need a value for each row in the table, such as adding a new field derived from existing data (e.g., creating a "Total Price" column by multiplying "Quantity" and "Price"). Performance: Since calculated columns are stored in the model,
  • 7. DIFFERENCE BETWEEN CALCULATED COLUMN AND MEASURE IN POWER BI In Power BI, both calculated columns and measures are used to perform calculations, but they serve different purposes and behave differently. Here's a comparison of the two:
  • 9. SUMX Formula in Power BI Definition: SUMX is an iterator function that performs row-by- row calculations and then sums the results. Example Total_Sales2 = SUMX(SalesData,SalesData[Quantity]*SalesData[Unit Price (INR)]) Use Case: Use SUMX when you need to perform a calculation for each row before summing, such as multiplying two columns together or applying conditional logic. Performance: SUMX can be slower than SUM because it performs calculations on each row individually before summing. It's ideal for more complex scenarios that require row context.
  • 10. Difference between SUM and SUMX Formula in Power BI In Power BI, both SUM and SUMX are used to perform summation, but they work differently and are used in different scenarios. Here's a breakdown of the key differences:
  • 12. Count Formula in Power BI Definition: COUNT counts the number of non-blank values in a column. Example Number of Customers = COUNT('Table'[Customer ID]) Use Case: When you want to count the non-empty values in a column.
  • 14. COUNTA Formula in Power BI Definition: COUNTA counts the number of non-blank values in a column, including text, numeric values, and logical values even counts Boolean values where only Count will not count Boolean data type Example Number of Reviews = COUNTA('Table'[Review Status]) Use Case: When you need to count all non-blank values, regardless of the data type (text, numbers, etc.).
  • 16. COUNTBLANK Formula in Power BI Definition: COUNTBLANK counts the number of blank (empty) values in a column. Example Blank Reveiws = COUNTBLANK('Table'[Review Points]) Use Case: When you want to count the number of blank or missing values in a column.
  • 18. COUNTROWS Formula in Power BI Definition: COUNTROWS counts the number of rows in a table. Example Total Records = COUNTROWS('Table') Use Case: When you want to count the total number of rows in a table or in a filtered table.
  • 20. DISTINCTCOUNT Formula Definition: DISTINCTCOUNT counts the number of unique, non-blank values in a column. Example Unique States = DISTINCTCOUNT('Table'[State]) Use Case: When you need to count the distinct (unique) values in a column, excluding blanks.
  • 22. COUNTX Formula Definition: COUNTX is an iterator function that counts non-blank results of an expression evaluated row by row over a table. Example Count Reviews >= 5 = COUNTX('Table', IF('Table'[Review Points] >= 5, 1, BLANK())) Use Case: When you need to count based on an expression that is evaluated for each row in a table.
  • 24. COUNTAX Formula Definition: COUNTAX is the iterator version of COUNTA. It evaluates an expression for each row and counts the number of non-blank results. Example Count True = COUNTAX(FILTER('Table','Table'[Review Status]=true),'Table'[Review Status]) Use Case: When you need to count based on an expression that is evaluated for each row in a table even there is Binary data type.
  • 26. COUNTROWS with FILTER Formula Definition: COUNTROWS can be used with the FILTER function to count rows that meet specific criteria. Example Maharashtra Count = COUNTROWS(FILTER('Table','Table'[State]="Maharashtra")) Use Case: When you want to count rows based on a condition or set of conditions.
  • 27. Summary of DAX Counting Functions: These functions provide flexibility depending on whether you're counting all rows, distinct values, non-blank values, or values based on expressions and conditions.
  • 30. Extract Day/Month/Year DAY(<datetime>) : Extracts the day from a date value. MONTH(<datetime>) : Extracts the month from a date value. YEAR(<datetime>) : Extracts the year from a date value.
  • 31. Extract Hour/Minute/Second Hour(<datetime>) : Extracts the Hour from a date and time value. Minute(<datetime>) : Extracts the Minute from a date and time value. Second(<datetime>) : Extracts the Second from a date and time value.
  • 32. Extract Hour/Minute/Second Today() : Show Current date Now() – Show current date and Time Weekday() – Show Weekday in numbers between 1 to 7 Weeknum() – Show Week number in Month/Year
  • 33. DatedIFF Formula Definition: Returns the difference between two dates in the specified interval (days, months, years, etc.). Syntax DATEDIFF(<start_date>, <end_date>, <interval>) Example DATEDIFF(Sales[OrderDate], Sales[ShipDate], DAY)
  • 35. 1 . Create Custom Calendar in Power Query Formula = List.Dates(#date(2023,1,1),731,#duration(1,0,0,0)) Creating a custom calendar using Power Query in Power BI is a common and essential task when dealing with date-related data, especially for performing time-based analysis like year-over-year (YoY), month-to-date (MTD), and quarter-to-date (QTD) comparisons. Having a custom date table ensures that you have control over the format, date ranges, and any specific time-based logic needed for your reports.
  • 36. 2. Create Custom Calendar in Power Query M Code let // Define start and end dates for the calendar StartDate = #date(2020, 1, 1), // You can change this to your desired start date EndDate = Date.From(DateTime.LocalNow()), // Automatically takes today's date as the end date // Generate a list of dates between the start and end dates DateList = List.Dates(StartDate, Duration.Days(EndDate - StartDate) + 1, #duration(1, 0, 0, 0)), // Convert the list into a table DateTable = Table.FromList(DateList, Splitter.SplitByNothing(), {"Date"}, null, ExtraValues.Error), // Add Year, Month, and Day columns for further analysis AddYear = Table.AddColumn(DateTable, "Year", each Date.Year([Date]), Int64.Type), AddMonth = Table.AddColumn(AddYear, "Month", each Date.Month([Date]), Int64.Type), AddDay = Table.AddColumn(AddMonth, "Day", each Date.Day([Date]), Int64.Type), AddMonthName = Table.AddColumn(AddDay, "Month Name", each Date.ToText([Date], "MMMM"), type text), AddQuarter = Table.AddColumn(AddMonthName, "Quarter", each Date.QuarterOfYear([Date]), Int64.Type), AddYearMonth = Table.AddColumn(AddQuarter, "Year-Month", each Date.ToText([Date], "yyyy- MM"), type text), AddWeekOfYear = Table.AddColumn(AddYearMonth, "Week of Year", each Date.WeekOfYear([Date]), Int64.Type), AddDayOfWeek = Table.AddColumn(AddWeekOfYear, "Day of Week", each Date.ToText([Date], "dddd"), type text),
  • 37. 3 . Calendar DAX Formula Formula = CALENDAR(MIN(SalesData[Date]),MAX(SalesData[Date])) The CALENDAR DAX function in Power BI is used to generate a continuous range of dates between a specified start and end date. It's particularly useful when building a date table, which is essential for time-based calculations such as year-over-year analysis, month-to-date, quarter-to- date, etc.
  • 38. 4 . CalendarAuto DAX Formula Formula = CALENDARAUTO() The CALENDARAUTO function in Power BI is a powerful tool for creating a date table that automatically detects the date range from all date columns in your data model. This means it scans your data and generates a date range based on the minimum and maximum dates found in the model, which is especially helpful for dynamic date tables without specifying start or end dates manually.
  • 39. MTD QTD AND YTD DAX FORMULA Sales MTD = TOTALMTD(SUM(Sales[SalesAmount] ), DateTable[Date] ) Sales QTD = TOTALQTD(SUM(Sales[SalesAmount] ), DateTable[Date] ) Sales YTD = TOTALYTD(SUM(Sales[SalesAmount] ), DateTable[Date] ) Formula MTD (Month-to-Date), QTD (Quarter-to-Date), and YTD (Year-to-Date) are commonly used DAX functions in Power BI for performing time-based aggregations. They are particularly helpful for tracking progress over the current month, quarter, or year , making it easy to see cumulative totals up to the present date. These functions rely on having a properly structured date table, ideally linked to your data model.
  • 40. Networkdays DAX Formula Network Days = NETWORKDAYS("01-01-2023","31-01- 2023",1,Holidays) Formula In Power BI, Network Days refers to the count of working days (typically Monday through Friday) between two specified dates, excluding weekends and optionally excluding holidays.
  • 41. Networkdays DAX Formula Network Days = NETWORKDAYS("01-01-2023","31-01- 2023",1,Holidays) 1 or omitted: Saturday, Sunday 2: Sunday, Monday 3: Monday, Tuesday 4: Tuesday, Wednesday 5: Wednesday, Thursday 6: Thursday, Friday 7: Friday, Saturday 11: Sunday only 12: Monday only 13: Tuesday only 14: Wednesday only 15: Thursday only 16: Friday only 17: Saturday only
  • 42. DATESINPERIOD DAX FORMULA DATESINPERIOD(<dates>, <start_date>, <number_of_intervals>, <interval>) Formula The DATESINPERIOD function in DAX returns a single-column table of dates within a specified period, based on a start date and a defined interval. It’s useful when you need to create calculations over dynamic date ranges (e.g., last 7 days, previous month, etc.).
  • 43. DATESBETWEEN DAX FORMULA DATESBETWEEN(<dates>, <start_date>, <end_date>) Formula The DATESBETWEEN function in DAX returns a table with dates within a specified start and end date range. This function is useful when you want to filter data to specific date boundaries.
  • 44. SAME PERIOD LAST YEAR DAX FORMULA SAMEPERIODLASTYEAR(<dates >) Formula The SAMEPERIODLASTYEAR function in DAX is used to return a table with the dates for the same period in the previous year . This function is often used in time intelligence calculations to compare current performance to the previous year.
  • 45. CALCULATE DAX FORMULA SAMEPERIODLASTYEAR(<dates >) Formula The SAMEPERIODLASTYEAR function in DAX is used to return a table with the dates for the same period in the previous year . This function is often used in time intelligence calculations to compare current performance to the previous year.
  • 46. TEXT FORMULAS In Power BI, there are several DAX functions designed for working with text data. These functions allow you to manipulate and format text values in various ways. Here are some commonly used text DAX formulas in Power BI: LEFT , RIGHT , MID LEFT("Power BI", 5) // Result: "Power" RIGHT("Power BI", 2) // Result: "BI" MID("Power BI", 7, 2) // Result: "BI"
  • 47. TEXT FORMULAS In Power BI, there are several DAX functions designed for working with text data. These functions allow you to manipulate and format text values in various ways. Here are some commonly used text DAX formulas in Power BI: UPPER and LOWER UPPER("Power BI") // Result: "POWER BI" LOWER("Power BI") // Result: "power bi" LEN: Returns the length (number of characters) of a text string.