Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

With or without EARLIER function?

I just learn what the EARLIER function does. But I found that there is a very similar expression that generates exactly the same result.

Here is the example and the calculated columns.

 

Example:

IndexNamewhatever
1a1
2b1
3c1
4d1
5b2
6a2
7b3
8b4
9e1
10f1
11e2
12b5
13c2
14a3

 

Calculated column 1:

with eariler countrow = 
    COUNTROWS(
        FILTER(example, 
                example[index] <= EARLIER(example[index]) 
                && example[name] = EARLIER(example[name])))

 

Calculated column 2:

wihout earlier countrow = 
var i = example[index]
var n = example[name]
return
    COUNTROWS(
        FILTER(example, 
                example[index] <= i 
                && example[name] = n))

 

Result:

hyman9090_1-1668502399808.png

Both calculated column 1 and calculated column 2 give the same result. I am wondering if they are equivalent expressions or just coincidently happen to be the same. If they are equivalent, that means the EARLIER function can actually be replaced by setting it as VAR?

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Both calculations end up doing the same thing. And we can use these approaches interchangeably

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Both calculations end up doing the same thing. And we can use these approaches interchangeably

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Have read lots of articles. I found out that they are just the same.

Anonymous
Not applicable

Yes, understand that they end up doing the same thing. But devils in the details, since I have no idea what principle or mechanism behind them, so I am worrying about if there are any occasions that make two different results by two different expressions (given that they are fundamentally not identical).

 

So are they actually equal to each other, simply just different expressions?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.