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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
GMajor67
Regular Visitor

Get Max Date from Slicer and Next Three Dates

Hello all,

 

Because I cannot create a dynamic table based on a current slicer, I am instead using a measure to set create a "filter" with a column of 1s and 0s to replicate the outcome I am looking for. Essentially I want to have the maximum date selected from the current date slicer (which are all consecutive months) and then the following 3 consecutive months. So if I have say Feb-24, Mar-24 and Apr-24 selected in the slicer, I would want my "filter" measure to return 0's for all dates except Apr-24, May-24, Jun-24 and Jul-24.

 

This is the measure that I have tried, but it is just returning 0s for all dates.

 

GMajor67_1-1722998770020.png

 

I would appreciate any help you could give on this.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @GMajor67 ,

 

I made simple samples and you can check the results below:

vtianyichmsft_0-1723083715634.png

vtianyichmsft_1-1723083723161.png

Measure = VAR _select = SELECTEDVALUE('Table 2'[Date])
RETURN IF(MAX('Table'[Date])>=_select&&MAX('Table'[Date])<=EDATE(_select,3),1,0)

 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

6 REPLIES 6
Anonymous
Not applicable

Hi @GMajor67 ,

 

I made simple samples and you can check the results below:

vtianyichmsft_0-1723083715634.png

vtianyichmsft_1-1723083723161.png

Measure = VAR _select = SELECTEDVALUE('Table 2'[Date])
RETURN IF(MAX('Table'[Date])>=_select&&MAX('Table'[Date])<=EDATE(_select,3),1,0)

 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Thanks @Anonymous - the key here too was to create a second date table to ensure all dates would appear in the visual but still leave filters active.

SachinNandanwar
Super User
Super User

What should happen if the user selection isnt continous ? For example use selects Mar24,June24 and Nov24.



Regards,
Sachin
Check out my Blog

Hi @SachinNandanwar , in that case the measure would return 1 for Nov-24, Dec-24, Jan-25 and Feb-25 and 0 elsewhere.

bhanu_gautam
Super User
Super User

@GMajor67 , Try using below measure

FourDatesFilter =
VAR PeriodStart = CALCULATE(MAX('Balance Sheet'[Date]), ALLSELECTED('Balance Sheet'))
VAR PeriodEnd = EDATE(PeriodStart, 3)
RETURN
IF(
    SELECTEDVALUE('Balance Sheet'[Date]) >= PeriodStart &&
    SELECTEDVALUE('Balance Sheet'[Date]) <= PeriodEnd,
    1,
    0
)



Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thanks for this @bhanu_gautam ...this looks similar to variations I have tried before. With your version, I get 0 as outputs in the measure except for the very last date in Balance Sheet[Date] (which shows 1 as the output for FourDatesFilter), even if not selected in the slicer. Any more thoughts?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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