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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
craigdent
Frequent Visitor

Help with dates between two rows

Hi all,

 

I have a table with payroll cut off dates and would like to filter another table based on results between each cut off date. I'm not sure where to start, I've thought about creating columns to show the first and last dates of each "month" but that hasn't worked so far.

 

So for example, I'd want to select November 2020 on a slicer dropdown, and get every approved record between the 4th October and 31st October, for December is would be 1st November to 28th November, etc.

 

Is this possible?

craigdent_0-1601473901382.png

 

Currently there is a date table which has a relationship to the Date column in the cut off table. The records I'd like to show are in another table which also has a relationship to the data table for a columns with an approved date.

 

10 REPLIES 10
amitchandak
Super User
Super User

@craigdent , Try like

 

measure =
var _Mtd = CALCULATE(Max(Table[Date]),DATESMTD('Date'[Date]))
var _lmt = CALCULATE(Max(Table[Date]),DATESMTD(dateadd('Date'[Date],-1,MONTH))) +1

return
calculate([measure], filter (all('Date') , 'Date'[Date]>= _lmt && 'Date'[Date]<=_Mtd))

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

Thanks @amitchandak,

 

I couldn't get this working either, I think because it assumes the next monthly cut off is the same day of the next month, however it varies depending on the lenght of the month and the next pay day (which could be earlier if it would fall on a weekend or bank holiday).

 

Also, the [measure] on the last line kept coming up with a circular error warning, should I ignore that?

@craigdent ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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
Fowmy
Super User
Super User

@craigdent 

You can have two measures with Start and End dates or use these techniques with FILTER function to filter the table.

Start Date = 
VAR _Date = SELECTEDVALUE(Table9[Date])
RETURN

CALCULATE(
    MAX(Table9[Date]),
    FILTER(
        ALL(Table9),
        Table9[Date] < _Date
    )
)
End Date = 
SELECTEDVALUE(Table9[Date])

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn






Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thank you @Fowmy 

 

I've tried to use this, would Table9 be the table that stores the cut off dates in my snip? Or is this the Date table itself?

 

I tried using that table (Overtime Deadlines) but it didn't bring anything up when I used it.

@craigdent

I did not take any dates table into my formula. You wanted to filter the table that you showed in the question based on the logic you mentioned. These formulas can be used to filter other tables. Why do not share a sample PBIX file with some sample data to check? Also, mention the expected result.

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube Linkedin

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

My .pbix can be found here: Overtime Report - wasn't sure how to attached a file as I kept getting an error saying the file type is not supported!

 

Ideally, what I'd like is a dropdown slicer at the top with the Month from the Overtime Deadlines table which the filters the table based on the ApprovedDatestamp - the ApprovedDatestamp must be before the Date that the Month relates to, but after the previous Date above it.

hi  @craigdent 

I'm a little confused by your description, what is your expected output in this sample pbix file.

Can you give me an example based the data.

 

Regards,

Lin

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

Hi Lin,

 

What I'm looking for is a slicer visual which can select from the Date field in the Overtime Deadlines table, which will then filter the main Table visual for those records with an ApprovedDatestamp before the selected date, but on or after the previous Date.

hi  @craigdent 

Could you show us the expected output with an example in your sample pbix file, that will be a great help.

 

Regards,

Lin

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.