cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NDataGeek Frequent Visitor
Frequent Visitor

Get value at earliest occurence date

Hi All,

I have a two tables with data as shown below

Capture.PNG

 

 

 

Capture 2.PNG

 

I wish to write a function that will return the value from the first table where the date is an exact match or the last occurence before dateOn. For instance CAM1 at dateOn 02/01/2011 would return value 43 and CAM6 at dateOn 05/01/2011 would return value 437

Any help is greatly appreciated. Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-cherch-msft Super Contributor
Super Contributor

Re: Get value at earliest occurence date

Hi @NDataGeek 

 

Could you show me the screenshot?Please check the formula <=.Please make sure there's no relationship between the two tables.

Column =
CALCULATE (
    SUM ( 'First Table'[values] ),
    TOPN (
        1,
        FILTER (
            'First Table',
            'First Table'[filed_name] = 'Second Table'[f_name]
                && 'First Table'[date] <= 'Second Table'[dateOn]
        ),
        'First Table'[date], DESC
    )
)

Regards,

Cherie

Community Support Team _ Cherie Chen
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

4 REPLIES 4
v-cherch-msft Super Contributor
Super Contributor

Re: Get value at earliest occurence date

Hi @NDataGeek 

 

You may try below calculated column.

Column =
CALCULATE (
    SUM ( 'First Table'[values] ),
    TOPN (
        1,
        FILTER (
            'First Table',
            'First Table'[filed_name] = 'Second Table'[f_name]
                && 'First Table'[date] <= 'Second Table'[dateOn]
        ),
        'First Table'[date], DESC
    )
)

1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
NDataGeek Frequent Visitor
Frequent Visitor

Re: Get value at earliest occurence date

Thanks Cherie for your quick reply.

Somehow, the calculated colum returns just the values where the dates is an exact match.

Typed the formula exactly. Don't know if am missing something.

v-cherch-msft Super Contributor
Super Contributor

Re: Get value at earliest occurence date

Hi @NDataGeek 

 

Could you show me the screenshot?Please check the formula <=.Please make sure there's no relationship between the two tables.

Column =
CALCULATE (
    SUM ( 'First Table'[values] ),
    TOPN (
        1,
        FILTER (
            'First Table',
            'First Table'[filed_name] = 'Second Table'[f_name]
                && 'First Table'[date] <= 'Second Table'[dateOn]
        ),
        'First Table'[date], DESC
    )
)

Regards,

Cherie

Community Support Team _ Cherie Chen
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

NDataGeek Frequent Visitor
Frequent Visitor

Re: Get value at earliest occurence date

There was a relationship between the tables.

Thanks, it works like a charm

 

Regards

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 262 members 2,873 guests
Please welcome our newest community members: