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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

This Calculate returns EARLIER/EARLIEST refers to an earlier row context which doesn't exist.

Hi, looking for some help with the error above. im using this function to calculate days in sequence. it returns an error that states i cant refer to an earlier row. any help is appreciated

 

 

SequenceDays = 
IF (
    'Table'[Group] = EARLIER ( 'Table'[Group] ),
    IF (
        DATEDIFF (
            EARLIER ( 'Table'[Date] ),
            'Table'[Date],
            DAY
        ) = 1,
        EARLIER ( 'Table'[SequenceDays] ) + 1,
        1
    ),
    1
)

 

 

2 ACCEPTED SOLUTIONS
v-binbinyu-msft
Community Support
Community Support

Hi @Anonymous ,

Please try below dax formula:

 

SequenceDays =
VAR cur_date =
    SELECTEDVALUE ( 'Table'[Date] )
VAR cur_group =
    SELECTEDVALUE ( 'Table'[Group] )
VAR cur_sqday =
    SELECTEDVALUE ( 'Table'[SequenceDays] )
VAR _val =
    IF (
        'Table'[Group] = cur_group,
        IF ( DATEDIFF ( cur_date, 'Table'[Date], DAY ) = 1, cur_sqday + 1, 1 ),
        1
    )
RETURN
    _val

 

If it doesn't work, please provide a screenshot of the results you are expecting and desensitized example data, it is very helpful for me to do test.

Thanks for your efforts & time in advance.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

No Luck im afraid, The issue is a circular reference error. I cant call the calculated column im creating as i create it, i need to work out a way to have it iterate somehow. 

View solution in original post

3 REPLIES 3
jedwards_CSS
Regular Visitor

So presumably, in this particular example, SOLVED means not-solved?

v-binbinyu-msft
Community Support
Community Support

Hi @Anonymous ,

Please try below dax formula:

 

SequenceDays =
VAR cur_date =
    SELECTEDVALUE ( 'Table'[Date] )
VAR cur_group =
    SELECTEDVALUE ( 'Table'[Group] )
VAR cur_sqday =
    SELECTEDVALUE ( 'Table'[SequenceDays] )
VAR _val =
    IF (
        'Table'[Group] = cur_group,
        IF ( DATEDIFF ( cur_date, 'Table'[Date], DAY ) = 1, cur_sqday + 1, 1 ),
        1
    )
RETURN
    _val

 

If it doesn't work, please provide a screenshot of the results you are expecting and desensitized example data, it is very helpful for me to do test.

Thanks for your efforts & time in advance.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

No Luck im afraid, The issue is a circular reference error. I cant call the calculated column im creating as i create it, i need to work out a way to have it iterate somehow. 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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