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
benjellounm
Regular Visitor

Filter based on date slicer

Hello, 

 

I have this complicated task and I hope someone can help me, I have this table where I have "Company name" & "Award Date", and I want to add a column where it shows which date is the latest award date for that specific vendor and that based on date slicer

 

table with all data

Company nameAward Date
xyz9/1/2020
xyz10/2/2020
xyz11/4/2020
xyz1/2/2021

 

add isLatest column with all data

Company nameAward DateisLatest
xyz9/1/2020No
xyz10/2/2020No
xyz11/4/2020No
xyz1/2/2021Yes

 

using the date slicer between 9/1/2020 and 10/2/2020

Company nameAward Datelatest
xyz9/1/2020No
xyz10/2/2020Yes

 

please help, 

 

Thanks in advance. 

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

Hi  @benjellounm ,

 

First create a calendar table as below:

Calendar = CALENDAR(MIN('Table'[Award Date]),MAX('Table'[Award Date]))

Then create a measure as below:

Measure =
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[Award Date] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Award Date] >= MINX ( ALLSELECTED ( 'Calendar' ), 'Calendar'[Date] )
                && 'Table'[Award Date] <= MAXX ( ALLSELECTED ( 'Calendar' ), 'Calendar'[Date] )
                && 'Table'[Company name] = MAX ( 'Table'[Company name] )
        )
    )
RETURN
    IF (
        MAX ( 'Table'[Award Date] )
            > MAXX ( ALLSELECTED ( 'Calendar' ), 'Calendar'[Date] ),
        BLANK (),
        IF ( MAX ( 'Table'[Award Date] ) = _maxdate, "Yes", "No" )
    )

And you will see:

vkellymsft_0-1628050063819.png

vkellymsft_1-1628050076974.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

5 REPLIES 5
v-kelly-msft
Community Support
Community Support

Hi  @benjellounm ,

 

First create a calendar table as below:

Calendar = CALENDAR(MIN('Table'[Award Date]),MAX('Table'[Award Date]))

Then create a measure as below:

Measure =
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[Award Date] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Award Date] >= MINX ( ALLSELECTED ( 'Calendar' ), 'Calendar'[Date] )
                && 'Table'[Award Date] <= MAXX ( ALLSELECTED ( 'Calendar' ), 'Calendar'[Date] )
                && 'Table'[Company name] = MAX ( 'Table'[Company name] )
        )
    )
RETURN
    IF (
        MAX ( 'Table'[Award Date] )
            > MAXX ( ALLSELECTED ( 'Calendar' ), 'Calendar'[Date] ),
        BLANK (),
        IF ( MAX ( 'Table'[Award Date] ) = _maxdate, "Yes", "No" )
    )

And you will see:

vkellymsft_0-1628050063819.png

vkellymsft_1-1628050076974.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

parry2k
Super User
Super User

@benjellounm not sure why, see the attached file and the award table. There are other tables in the file, just ignore those.

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@benjellounm add a measure using following expression and it will take care of it:

 

 

isLatest = 
VAR __awardDate = MAX ( Award[Award Date] )
VAR __maxDate = 
CALCULATE ( 
     MAX ( Award[Award Date] ), 
     TOPN ( 1, ALLSELECTED ( Award ),  CALCULATE ( MAX ( Award[Award Date] ), VALUES ( Award[Company name] ) ) , DESC )
) 
RETURN
IF ( __awardDate = __maxDate, "Yes", "No" )

 

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hello - Thank you for the help but it didn't work, I got all "Yes" for all the dates

 

Company nameAward DateisLatest
xyz9/1/2020Yes
xyz10/2/2020Yes
xyz11/4/2020Yes
xyz1/2/2021Yes
amitchandak
Super User
Super User

@benjellounm , You can create measure

If( max(Table[Date]) = calculate(max(Table[Date]), filter(allselected(Table), Table[Date] =max(Table[Date]))) , "Yes", "No")

 

 

Column does not take slicer values , so you have to use a measure

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.