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
Anonymous
Not applicable

Return max date given criteria

Hello,

I have a table of data that look like the below:

DatesAreaTo display?
01-Jan-201No
02-Jan-201No
03-Jan-201No
04-Jan-201No
05-Jan-201Yes
06-Jan-201No
07-Jan-201No
08-Jan-201No
09-Jan-201Yes
01-Jan-202No
02-Jan-202No
03-Jan-202Yes
04-Jan-202No
05-Jan-202No
06-Jan-202Yes
07-Jan-202No
08-Jan-202No
09-Jan-202No
01-Jan-203Yes
02-Jan-203Yes
03-Jan-203No
04-Jan-203No
05-Jan-203No
06-Jan-203No
07-Jan-203No
08-Jan-203No
09-Jan-203No

 

I want to create a table so it returns the most recent date with a "Yes". The resulting table should look like this:

AreaYes
109-Jan-20
206-Jan-20
302-Jan-20

 

How can I accomplish this?

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

How about this?

MAX_DATE =
CALCULATE (
    MAX ( YESTABLE[Dates] ),
    ALLEXCEPT ( GEOGRAPHY, GEOGRAPHY[AREA] ),
    YESTABLE[To display] = "Yes"
)

 

If it doesn't work, please share us some sample data of your two tables, removing sensitive information.

 

 

Best Regards,

Icey

 

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

5 REPLIES 5
Icey
Community Support
Community Support

Hi @Anonymous ,

 

How about this?

MAX_DATE =
CALCULATE (
    MAX ( YESTABLE[Dates] ),
    ALLEXCEPT ( GEOGRAPHY, GEOGRAPHY[AREA] ),
    YESTABLE[To display] = "Yes"
)

 

If it doesn't work, please share us some sample data of your two tables, removing sensitive information.

 

 

Best Regards,

Icey

 

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

pranit828
Community Champion
Community Champion

Hi @Anonymous 

I would use

MAX_DATE = CALCULATE(MAX(table[Dates]),FILTER(ALLEXCEPT(table,table[Area]),table[To display] = "Yes")

and plot it using matrix





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile
Anonymous
Not applicable

Thank you. My issue is that Table[area] isn't part of the Table. "Area" comes from another table and is brought here through a relationship. 

HI @Anonymous 

 

In that case you need to create a relationship between both tables.

pranit828_0-1597946424599.png

 





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile
Anonymous
Not applicable

The relationship has already been created, so how should I re-write this part of the code?

FILTER(ALLEXCEPT(YESTABLE, GEOGRAPHY[AREA]) doesn't seem to work.

FILTER(ALLEXCEPT(table,table[Area]

 

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.