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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Amos_Lim
Resolver I
Resolver I

DAX Synex EARLIER Error

Hi,

 

My code keeps showing EARLIER/EARLIEST refers to an earlier row context which doesn't exist..

Any help would appreciate. Thanks.

 

Rank = RANKX(FILTER('ForkLiftData', 'ForkLiftData'[SAP Number] = EARLIER('ForkLiftData'[SAP Number])), 'ForkLiftData'[ForkLift Name],,ASC)
12 REPLIES 12
rohit1991
Super User
Super User

Hi @Amos_Lim ,


The error with EARLIER in your DAX formula occurs because EARLIER needs a valid outer row context to reference, but there’s none in your calculation.


Solution

You can rewrite your formula to avoid EARLIER entirely. Use variables or ADDCOLUMN to create row contexts explicitly.

Updated Formula for a Calculated Column

If this is a calculated column:

 

Rank =
RANKX(
    FILTER(
        'ForkLiftData',
        'ForkLiftData'[SAP Number] = EARLIER('ForkLiftData'[SAP Number])
    ),
    'ForkLiftData'[ForkLift Name],
    ,
    ASC
)

 

This should work if the column is being calculated row by row. If it doesn’t, consider the alternatives below.

Alternative 1: Using VAR and ALL

To avoid EARLIER, explicitly define the context using VAR and ALL:

Rank =
VAR CurrentSAPNumber = 'ForkLiftData'[SAP Number]
RETURN
RANKX(
    FILTER(
        ALL('ForkLiftData'),
        'ForkLiftData'[SAP Number] = CurrentSAPNumber
    ),
    'ForkLiftData'[ForkLift Name],
    ,
    ASC
)



Alternative 2: Using GROUPBY (for aggregated contexts)

If you're ranking based on groups (e.g., SAP Number groups), use GROUPBY to create a new table first:

Rank =
RANKX(
    GROUPBY(
        'ForkLiftData',
        'ForkLiftData'[SAP Number],
        "ForkLiftName", MAX('ForkLiftData'[ForkLift Name])
    ),
    [ForkLiftName],
    ,
    ASC
)

 

When to Use These Solutions

  • Use Alternative 1 if you’re creating a calculated column or need a simple row-wise ranking.
  • Use Alternative 2 if you're working with aggregated groups or want more explicit control over the grouping.

 

 

 

 

 

 

 

Bibiano_Geraldo
Super User
Super User

Hi @Amos_Lim ,

Whats is the criteria for rank? what will determine to forklift stand in first position or last? please give more details to help you

Is this post help you? Please consider to:

Accept as Solution!
Give a Kudo
Follow me on Linkedin

I am trying to use DAX to rank the forklifts for each user.

 

Amos_Lim_1-1737774589191.png

 

and use DAX to display user details only for the first row of each user. Repeat the same DAX for other column except ForkLift Name

Amos_Lim_2-1737774654564.png

 

In summary:-

My intension was to make the table in the PBI dashboard that listed all users and the forklifts they are authorized to drive.

 

and currently, the table displays multiple rows of the same user, with their 'User Name', 'SAP Number', 'Forklift Name', 'POC', 'Department', and 'License Valid Until' if the user has access to different forklifts.


So for repeated user, I would like to just display their information in the 1st row, and for the 2nd or 3rd or more with the same user will just shows the different ForkLift and the rest of the columns show "Blank"?

 

Amos_Lim_0-1737774213239.png

 

grazitti_sapna
Super User
Super User

Hi @Amos_Lim
Please try using this DAX measure.


Rank =
RANKX(
FILTER(
'ForkLiftData',
'ForkLiftData'[SAP Number] = SELECTEDVALUE('ForkLiftData'[SAP Number])
),
'ForkLiftData'[ForkLift Name],
,
ASC
)

🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!

 

It gives and error message

A single value for column 'ForkLift Name' in table 'ForkLiftData' cannot be determined. this can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count or sum to get a single result

Could you please share sample data, along with your expected result and any relevant logic.

If possible, upload a simplified .pbix file using this guide:

 How to upload PBI in Community

I have attached a sample PBIX file along with the expected results.

Amos_Lim_3-1737721951802.png

 

 

Excel 

Sample File 

Hi,

Show the expected result in another column of the Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

The Excel file contained raw data for all users, including their Name, SAP Number, POC, Department, Forklift License Valid Until date, and the Forklifts they are authorized to operate.

I duplicated the sheet to illustrate the expected outcome in the Power BI dashboard.

Excel with Expected Result Sheet 

Amos_Lim
Resolver I
Resolver I

I have taken a screenshot of the error and would like to resolve the issue as follows:

If a user (highlighted with a red arrow) appears for both Nichiyu and TCM forklifts, their information should only be displayed once. In the second row, only "TCM" should be shown instead of repeating the user's details. This approach will make the table easier to read, especially since it is a lengthy list.

 

Amos_Lim_0-1737674988527.png

 

Ritaf1983
Super User
Super User

Hi @Amos_Lim 

Please share sample data (excluding sensitive information) in text format, along with your expected result and any relevant logic. For guidance, refer to

How to provide sample data in the Power BI Forum

If possible, upload a simplified .pbix file using this guide:

 How to upload PBI in Community

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
bhanu_gautam
Super User
Super User

@Amos_Lim Try using this

Rank =
VAR CurrentSAPNumber = 'ForkLiftData'[SAP Number]
RETURN
RANKX(
FILTER('ForkLiftData', 'ForkLiftData'[SAP Number] = CurrentSAPNumber),
'ForkLiftData'[ForkLift Name],
,
ASC
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.