A
C
- CALCULATE
- CALCULATETABLE
- CALENDAR
- CALENDARAUTO
- CEILING
- CHISQ.DIST
- CHISQ.DIST.RT
- CHISQ.INV
- CHISQ.INV.RT
- CLOSINGBALANCEMONTH
- CLOSINGBALANCEQUARTER
- CLOSINGBALANCEYEAR
- COALESCE
- COLUMNSTATISTICS
- COMBIN
- COMBINA
- COMBINEVALUES
- CONCATENATE
- CONCATENATEX
- CONFIDENCE.NORM
- CONFIDENCE.T
- CONTAINS
- CONTAINSROW
- CONTAINSSTRING
- CONTAINSSTRINGEXACT
- CONVERT
- COS
- COSH
- COT
- COTH
- COUNT
- COUNTA
- COUNTAX
- COUNTBLANK
- COUNTROWS
- COUNTX
- COUPDAYBS
- COUPDAYS
- COUPDAYSNC
- COUPNCD
- COUPNUM
- COUPPCD
- CROSSFILTER
- CROSSJOIN
- CUMIPMT
- CUMPRINC
- CURRENCY
- CURRENTGROUP
- CUSTOMDATA
D
E
I
N
O
P
R
S
- SAMEPERIODLASTYEAR
- SAMPLE
- SEARCH
- SECOND
- SELECTCOLUMNS
- SELECTEDMEASURE
- SELECTEDMEASUREFORMATSTRING
- SELECTEDMEASURENAME
- SELECTEDVALUE
- SIGN
- SIN
- SINH
- SLN
- SQRT
- SQRTPI
- STARTOFMONTH
- STARTOFQUARTER
- STARTOFYEAR
- STDEVX.P
- STDEVX.S
- STDEV.P
- STDEV.S
- SUBSTITUTE
- SUBSTITUTEWITHINDEX
- SUM
- SUMMARIZE
- SUMMARIZECOLUMNS
- SUMX
- SWITCH
- SYD
T
U
EARLIEST is a powerful DAX function that allows you to return the first value for a given column within a specified context. In this article, we’ll explore how to use the EARLIEST function in Power BI to gain valuable insights into your data.
Understanding the EARLIEST Function
The EARLIEST function is used to retrieve the first value in a column that is related to a specific context. For example, let’s say you have a table of sales data that includes the date and revenue for each transaction. You could use the EARLIEST function to retrieve the first date for each customer, which could be useful for analyzing customer behavior over time.
The syntax for the EARLIEST function is as follows:
EARLIEST(❰column❱, [❰filter❱])
The first parameter is the column for which you want to retrieve the first value. The second parameter, which is optional, is a filter that restricts the context for the calculation.
Examples of Using EARLIEST
Let's look at a few examples of how to use the EARLIEST function in Power BI.
Example 1: Retrieving the First Date for Each Customer
Suppose you have a table of sales data that includes the following columns:
- Customer ID
- Date
- Revenue
You want to retrieve the first date for each customer, which could be useful for analyzing customer behavior over time.
To do this, you would create a new measure and use the EARLIEST function as follows:
First Purchase Date = EARLIEST(Sales[Date],Sales[Customer ID])
This formula retrieves the earliest date in the Sales[Date] column that is related to the current context of the Sales[Customer ID] column.
Example 2: Retrieving the First Date for Each Product
Suppose you have a table of sales data that includes the following columns:
- Product ID
- Date
- Revenue
You want to retrieve the first date for each product, which could be useful for analyzing product performance over time.
To do this, you would create a new measure and use the EARLIEST function as follows:
First Purchase Date = EARLIEST(Sales[Date],Sales[Product ID])
This formula retrieves the earliest date in the Sales[Date] column that is related to the current context of the Sales[Product ID] column.
Example 3: Retrieving the First Date for All Transactions
Suppose you have a table of sales data that includes the following columns:
- Transaction ID
- Date
- Revenue
You want to retrieve the first date for all transactions, regardless of customer or product.
To do this, you would create a new measure and use the EARLIEST function as follows:
First Purchase Date = EARLIEST(Sales[Date])
This formula retrieves the earliest date in the Sales[Date] column, without any additional filters.
The EARLIEST function is a powerful tool for retrieving the first value for a given column within a specified context. By using EARLIEST in your DAX formulas, you can gain valuable insights into your data and make more informed business decisions.