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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Swilson2112
Frequent Visitor

Return a value from a table based on comparing two different fields in that same table..

I have this table: 

 

I want to compare the Invoice Date Column vs the Change Date Time Column and then return the Last Daily Change for the Change Date Time that has the closest before value.

 

In this example below:

Invoice Date:                                                               1/15/2021

Closest before Change Date and Time:                       6/14/19 15:17

Last Daily Change:                                                       .4495

 

I would like to create this as a DAX measure and insert the Last Daily Change Value into an existing visual on my dashboard that is showing Invoice#, Invoice date and some other sales information.

INVOICEINVOICE DATEPart #LINEFIELD_NAMEBEFOREAFTERDATE_CHGLast Daily ChangeChanged Date Time
225551/15/21100-1100Rate 0.4152/8/190.4152/8/19 11:09
225551/15/21100-1100Rate0.4150.492/13/190.492/13/19 6:27
225551/15/21100-1100Rate0.490.51952/27/190.51952/27/19 12:19
225551/15/21100-1100Rate0.51950.44956/14/190.44956/14/19 15:17
225551/15/21100-1100Rate0.44950.915/17/210.915/17/21 10:48
225551/15/21100-1100Rate0.911.129/22/211.129/22/21 16:30
225551/15/21100-1100Rate1.120.449512/3/211.1212/3/21 7:28
225551/15/21100-1100Rate0.44951.1212/3/211.1212/3/21 7:30
225551/15/21100-1100Rate1.120.449512/10/211.1212/10/21 6:53
225551/15/21100-1100Rate0.44950.9112/10/211.1212/10/21 7:10
225551/15/21100-1100Rate0.911.1212/10/211.1212/10/21 7:12
225551/15/21100-1100Rate1.120.9112/10/211.1212/10/21 7:18
225551/15/21100-1100Rate0.911.1212/10/211.1212/10/21 7:19
225551/15/21100-1100Rate1.120.43951/26/221.121/26/22 16:09
225551/15/21100-1100Rate0.43950.84551/26/221.121/26/22 16:42
225551/15/21100-1100Rate0.84550.911/26/221.121/26/22 16:43
225551/15/21100-1100Rate0.910.9651/26/221.121/26/22 16:44
225551/15/21100-1100Rate0.9651.021/26/221.121/26/22 16:45
225551/15/21100-1100Rate1.021.121/26/221.121/26/22 16:46
1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @Swilson2112 ,

 

You may try this Measure.

Last Daily Change Value =

VAR max_date =

    MAXX (

        FILTER ( 'Table', 'Table'[INVOICE DATE] > 'Table'[Changed Date Time] ),

        'Table'[Changed Date Time]

    )

RETURN

    CALCULATE (

        MAX ( 'Table'[Last Daily Change] ),

        FILTER ( 'Table', 'Table'[Changed Date Time] = max_date ),

        VALUES ( 'Table'[INVOICE] )

    )

 

Then, the result will look like this.

vcazhengmsft_0-1645426159072.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

1 REPLY 1
v-cazheng-msft
Community Support
Community Support

Hi @Swilson2112 ,

 

You may try this Measure.

Last Daily Change Value =

VAR max_date =

    MAXX (

        FILTER ( 'Table', 'Table'[INVOICE DATE] > 'Table'[Changed Date Time] ),

        'Table'[Changed Date Time]

    )

RETURN

    CALCULATE (

        MAX ( 'Table'[Last Daily Change] ),

        FILTER ( 'Table', 'Table'[Changed Date Time] = max_date ),

        VALUES ( 'Table'[INVOICE] )

    )

 

Then, the result will look like this.

vcazhengmsft_0-1645426159072.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.