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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
carrl284
Frequent Visitor

Help with Measure to return min date in slicer or date in row

Hi

 

I have a table as below.

PersonIdActivityStartEnd
1Working01/10/202014/10/2020
1Travel15/10/202015/10/2020
1Travel25/10/202025/10/2020
1Training26/10/202026/10/2020
1Absent27/10/202028/10/2020
1Working29/10/202015/11/2020
2Working23/09/202013/10/2020
2Travel14/10/202014/10/2020
2Travel23/10/202024/10/2020
2Working25/10/202003/11/2020


I have a between date slicer which uses a disconnected date table and a filter measure so that only rows that contain the dates in the slicer are shown.  This works fine but I would like to know how to write a measure that replaces the Start date with the Min date in the slicer if the start date < date in slicer.  I wrote this measure

 

Date From =
IF (
MIN ( Activity[Start] ) < MIN ( Dates[Date] ),
MIN ( Dates[Date] ),
MIN ( Activity[Start] )
)

It works fine until I remove the Start and End dates from the table visual, then it groups the activities together.  I would like to know how to write the measure so that all the rows are visible

 

PersonIdActivityDate From
1Working05/10/2020
1Travel15/10/2020
1Training26/10/2020
1Absent27/10/2020
2Working05/10/2020
2Travel14/10/2020

 

Many Thanks 

6 REPLIES 6
Anonymous
Not applicable

Hi  @carrl284 ,

If your users are willing to receive this answer, please mark our reply.

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

Hi  @carrl284 ,

Here are the steps you can follow:

1. Create a calendar table.

Date = CALENDARAUTO()

2. Create measure.

Start1 =
var _selected=SELECTEDVALUE('Date'[Date])
var _min=MAXX(FILTER(ALL('Table'),[PersonId]=MAX('Table'[PersonId])&&[Start]<=_selected),[Start])
var _max=MAXX(FILTER(ALL('Table'),[PersonId]=MAX([PersonId])),[Start])
return
SWITCH(
    TRUE(),
    MAX([Start])=_min,_selected,
    MAX([Start])=_max,_max,
    BLANK())

3. Result.

Start1 is the selected date and will override the latest date

v-yangliu-msft_0-1606700112226.jpeg

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

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

Hi @v-yangliu-msft and @amitchandak

Thanks for the measures and the pbix but they don't do what I need but I think that is because as you say @amitchandak my question isn't very clear. If I leave in the original start and end dates I have the context I need. MY users are happy to accept this as a solution. I will work on my questioning for next time.

Thanks again

amitchandak
Super User
Super User

@carrl284 ,

var _max = maxx(allselected('Date') , 'Date'[Date]), can you max date and you can use that in filter as per need

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
carrl284
Frequent Visitor

Let me see if I can clarify, There are 2 rows for PersonId 1 where the activity is Working.  If I filter from 5 Oct - 31 Oct my measure amalgamates those 2 rows into 1 and gives the start date as 5 Oct but I want it to return both rows the first one would start 5 October and the 2nd row would start 29 Oct. I would create a similar measure for End.

amitchandak
Super User
Super User

@carrl284 , Not very clear. Try like

 

Measure =
var _min = minx(allselected('Date') , 'Date'[Date])
return
calculate(countrows(Table), Filter(Table, Table[Start Date] <_min))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.