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

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

Hi @Anonymous 

 

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
Employee
Employee

Hi @Anonymous 

 

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.
Anonymous
Not applicable

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.

Hi @Anonymous 

 

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.
Anonymous
Not applicable

There was a relationship between the tables.

Thanks, it works like a charm

 

Regards

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.