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
mpicca13
Resolver IV
Resolver IV

DAX: Return a date value from a column that is closest to another date value from a row

Little stuck with this one.

I need to return the closest date value from [Last Pay Period Paycheck Column] that is <= the value within each row from column [End of Next Month]

 

Example: [End of Next Month] = 2/29/2020

                The closest date value in [Last Pay Period Paycheck Date] that is <= 2/29/2020 woud be 2/28/2020:

               Expected Result would be:      [Test] = 2/28/2020

 

See Image below for reference and current outputs:

Capture.PNG

1 ACCEPTED SOLUTION
edhans
Super User
Super User

Is this what you need? It is a calculated column. You didnt' specify but you are showing a table.

 

Test = 
VAR NextMonthDate = 'Table'[End of Next Month]
RETURN
MAXX(
    FILTER(
        'Table',
        'Table'[Last Payperiod Check Date] <= NextMonthDate
    ),'Table'[Last Payperiod Check Date]
)

 

2020-06-02 16_23_31-Untitled - Power BI Desktop.png

If not, can you post some actual data with expected results using the directions below?

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

3 REPLIES 3
edhans
Super User
Super User

Is this what you need? It is a calculated column. You didnt' specify but you are showing a table.

 

Test = 
VAR NextMonthDate = 'Table'[End of Next Month]
RETURN
MAXX(
    FILTER(
        'Table',
        'Table'[Last Payperiod Check Date] <= NextMonthDate
    ),'Table'[Last Payperiod Check Date]
)

 

2020-06-02 16_23_31-Untitled - Power BI Desktop.png

If not, can you post some actual data with expected results using the directions below?

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

That is exactly what I needed, thank you sir!

Excellent @mpicca13 

Glad to help out!



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.