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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
BlakeNol
Frequent Visitor

Max Date with filter / selection

Hi Everyone,

 

I think this should be easy. The data is pretty simple, it is a table with EntDate (the day the data was entered) and Volume (the volume recorded on that day). I would like to have a card that displays the volume on the last day that is selected via slicer. I would like the other card to display the average volume of the period selected.

 

I can get this to work without a slicer, but once I narrow the date range via slicer the cards do not work.

 

I created 2 custom date mesauses

MaxDate = CALCULATE(Max(PrdQuery[EntDate]),All(PrdQuery))

This always returns the last date in the data set

 

MaxDateSelection = LASTDATE(PrdQuery[EntDate])

This returns the entry date in the data set based on the filter in the slicer. I want this measure to return the last date in the selection, similar to how MaxDate returns the last date in the entire data set.

 

I can get this to work to always return the value for the last day in the dataset by creating another measure that compares MaxDate to EntDate and filter the visual off this measure. I would like to use the same strategy for the last filtered/selected date.Screenshot

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion
3 REPLIES 3
Anonymous
Not applicable

Ive had a similar issue without any sorting or linked table issues. Im using an ALL filter in PBI to return the last yearPeriod in my data 202208. CALCULATE(max(Data[YearMonth]),all(Data[YearMonth])). Its fine until my data filtering (slicers) excludes records with that date then it refers to the max data available in my case 201908. In my eyes ALL should mean ALL. In the end, in my Transform layer I created a reference to my main data as an orphan table then took the max of the Year Month as a single record. I then used the following formula. CALCULATE(max(CM[YearMonth])) where CM is my orphan record. Again ALL should mean ALL and it doesnt inspire confidence when something as fundemental as this doesnt work properly.

Sean
Community Champion
Community Champion

BlakeNol
Frequent Visitor

Thanks! I was pretty sure I tried this yesterday, but I guess not. 

 

For clarity, the formula is:

 

MaxDateAllSelected = CALCULATE(Max(PrdQuery[EntDate]),ALLSELECTED(PrdQuery))

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.