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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kormosb
Helper III
Helper III

EARLIER function

Hi Guys,

 

I am trying to use the EARLIER function as seen in the below picture, but it doesn't work. The poin is, that I am trying to get the solving day of the earlier date, if the "latest update date" is blank or 2020.03.26.

EARLIER ISSUE.png

I wonder if you could help me get the expected result (2).

 

Thanks in advance,

Benjamin

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

HI @kormosb,

You can try to use following calculate column formula, it can extract the last date and previous date to find out corresponding values:

 

last date value =
VAR prevDate =
    CALCULATE (
        MAX ( 'Issue Navigator'[Latest refresh date] ),
        FILTER (
            'Issue Navigator',
            [Key] = EARLIER ( 'Issue Navigator'[Key] )
                && DATEVALUE ( [Latest refresh date] )
                    < DATEVALUE ( EARLIER ( 'Issue Navigator'[Latest refresh date] ) )
        )
    )
RETURN
    IF (
        'Issue Navigator'[Latest refresh date] = BLANK ()
            || DATEVALUE ( 'Issue Navigator'[Latest refresh date] )
                = DATEVALUE ( MAX ( 'Issue Navigator'[Latest refresh date] ) ),
        CALCULATE (
            MAX ( 'Issue Navigator'[Solving day (original)] ),
            FILTER (
                'Issue Navigator',
                [Key] = EARLIER ( 'Issue Navigator'[Key] )
                    && [Latest refresh date] = prevDate
            )
        ),
       'Issue Navigator'[Solving day (original)]
    )

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

HI @kormosb,

You can extract the variable and use in a new calculated column to compare with current date:

Status =
VAR prevDate =
    CALCULATE (
        MAX ( 'Issue Navigator'[Latest refresh date] ),
        FILTER (
            'Issue Navigator',
            [Key] = EARLIER ( 'Issue Navigator'[Key] )
                && DATEVALUE ( [Latest refresh date] )
                    < DATEVALUE ( EARLIER ( 'Issue Navigator'[Latest refresh date] ) )
        )
    )
RETURN
    IF ( 'Issue Navigator'[Latest refresh date] >= prevDate, "Done" )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

8 REPLIES 8
v-shex-msft
Community Support
Community Support

HI @kormosb,

You can try to use following calculate column formula, it can extract the last date and previous date to find out corresponding values:

 

last date value =
VAR prevDate =
    CALCULATE (
        MAX ( 'Issue Navigator'[Latest refresh date] ),
        FILTER (
            'Issue Navigator',
            [Key] = EARLIER ( 'Issue Navigator'[Key] )
                && DATEVALUE ( [Latest refresh date] )
                    < DATEVALUE ( EARLIER ( 'Issue Navigator'[Latest refresh date] ) )
        )
    )
RETURN
    IF (
        'Issue Navigator'[Latest refresh date] = BLANK ()
            || DATEVALUE ( 'Issue Navigator'[Latest refresh date] )
                = DATEVALUE ( MAX ( 'Issue Navigator'[Latest refresh date] ) ),
        CALCULATE (
            MAX ( 'Issue Navigator'[Solving day (original)] ),
            FILTER (
                'Issue Navigator',
                [Key] = EARLIER ( 'Issue Navigator'[Key] )
                    && [Latest refresh date] = prevDate
            )
        ),
       'Issue Navigator'[Solving day (original)]
    )

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi,

 

Thanks for the solution, it's good, but I have faced some other issues with it.

What I truly need can be seen in the below picture. So not the last date value that I really need, I need the value when the [solution] column was first changed to "Done". In this case, the "Solving day" was 2, since 2020.03.18 was the frist date that it was accepted as "done".

earlier issue 3.JPG

I wonder if you could help me with this as well?

 

Thanks in advance,

Ben

HI @kormosb,

You can extract the variable and use in a new calculated column to compare with current date:

Status =
VAR prevDate =
    CALCULATE (
        MAX ( 'Issue Navigator'[Latest refresh date] ),
        FILTER (
            'Issue Navigator',
            [Key] = EARLIER ( 'Issue Navigator'[Key] )
                && DATEVALUE ( [Latest refresh date] )
                    < DATEVALUE ( EARLIER ( 'Issue Navigator'[Latest refresh date] ) )
        )
    )
RETURN
    IF ( 'Issue Navigator'[Latest refresh date] >= prevDate, "Done" )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

Create new columns like

max last date = maxx(filter(table, table[date]<earlier(Table[date]) && not(isbalnk(Table[value]))),Table[date])
last date value =maxx(filter(table, table[date]=earlier(Table[max last date ])),Table[value])

Unfortunately it doesn't work, as you can see below, but thanks for the idea.

earlier issue 2.png

Do you have any other tip for it? @amitchandak 

 

@kormosb 

Can you share sample data and sample output.

Yes, here you are.

sample 

az38
Community Champion
Community Champion

Hi @kormosb 

I see a few columns in your statement that aren't presented in data example

and please to facilitate help you copy-paste your example (both statement and data example) as text, not as screenshots


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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