Forum Discussion
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?
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
- FowmySuper 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 🙂
- FowmySuper User
@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 🙂
- amitchandakSuper 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))) +1return
calculate([measure], filter (all('Date') , 'Date'[Date]>= _lmt && 'Date'[Date]<=_Mtd))- craigdentFrequent Visitor
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?
- amitchandakSuper User
craigdent ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.