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
rima_ch
Frequent Visitor

Get max date from all the previous date

I am trying to get the maximum of all the previous dates based on the selected date, I try to create a column but it returns null; 

this is what I want to do: I have to add a new column to my table "Previous"(which is the maximum date for all the dates that are< to date "for that row"

dATE.PNG

 

thank you in advance 

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @rima_ch 

You can try formula as below:

Previous =
CALCULATE (
    MAX ( 'Table'[Date] ),
    FILTER ( ALL ( 'Table' ), 'Table'[Date] < EARLIER ( 'Table'[Date] ) )
)

Snipaste_2022-01-12_14-16-50.png

If it can't meet your requirement, please share you sample file for further researh.

 

Best Regards,
Community Support Team _ Eason

View solution in original post

4 REPLIES 4
v-easonf-msft
Community Support
Community Support

Hi, @rima_ch 

You can try formula as below:

Previous =
CALCULATE (
    MAX ( 'Table'[Date] ),
    FILTER ( ALL ( 'Table' ), 'Table'[Date] < EARLIER ( 'Table'[Date] ) )
)

Snipaste_2022-01-12_14-16-50.png

If it can't meet your requirement, please share you sample file for further researh.

 

Best Regards,
Community Support Team _ Eason

samdthompson
Memorable Member
Memorable Member

Hello, my approach would be to do this is power query.

 

1. Create a table with Date,Previous in power query and sort it by Date <Descending>. Getting the dates will really depend heavily on what your underlying data looks like. The end result will look like the example you have above.

1. Make two duplicates of the new table in power query. 

2. to each of the new tables add an index column starting at 0 on the first and then at 1 on the second.

3. Merge the two queries together using the index column as the join key (full outer join)

4. expand out the date from the second table of the join.

5. Add a custom column to the new table with logic to account for the result you need in the earliest date

 

depending on your uses, these tables can be set to load or not within powerbi or used to merge into other tables

 

 

// if this is a solution please mark as such. Kudos always appreciated.
smpa01
Super User
Super User

@rima_ch  provide sample data, hard to guess otherwise.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

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.