Forum Discussion
lkarolak
8 years agoFrequent Visitor
Grouping by consecutive dates into date ranges
This is my current data table structure: Date Name --------------------- 01.03.2018 Mark 02.03.2018 Mark 03.03.2018 Mark 07.03.2018 John 08.03.2018 John 15.03.2018 Steve ...
- 8 years ago
Essentially I have added 3 calculated columns to identify the boundaries of consective dates which can then be used for Groupings
SeriesBoundaries = VAR PriorName = CALCULATE ( VALUES ( TableName[Name] ), FILTER ( ALLEXCEPT ( TableName, TableName[Name] ), TableName[SeriesStart] = EARLIER ( TableName[SeriesStart] ) - 1 ) ) VAR NextName = CALCULATE ( VALUES ( TableName[Name] ), FILTER ( ALLEXCEPT ( TableName, TableName[Name] ), TableName[SeriesStart] = EARLIER ( TableName[SeriesStart] ) + 1 ) ) RETURN IF ( PriorName <> TableName[Name], "Series Start", IF ( NextName <> TableName[Name], "Series End" ) ) - 8 years ago
HI lkarolak
Please change the formua of Series Start as follows
SeriesStart = VAR PreviousDate = CALCULATE ( MAX ( TableName[Date ] ), FILTER ( TableName, TableName[Date ] < EARLIER ( TableName[Date ] ) ) ) VAR PreviousName = CALCULATE ( FIRSTNONBLANK ( TableName[Name], 1 ), FILTER ( TableName, TableName[Date ] = PreviousDate ) ) VAR myrank = RANKX ( TableName, TableName[Date ],, ASC, DENSE ) RETURN IF ( PreviousDate <> TableName[Date ] - 1 && TableName[Name] = PreviousName, myrank + 1, myrank )
Zubair_Muhammad
Community Champion
8 years agoZubair_Muhammad
Community Champion
8 years ago
Essentially I have added 3 calculated columns to identify the boundaries of consective dates which can then be used for Groupings
SeriesBoundaries =
VAR PriorName =
CALCULATE (
VALUES ( TableName[Name] ),
FILTER (
ALLEXCEPT ( TableName, TableName[Name] ),
TableName[SeriesStart]
= EARLIER ( TableName[SeriesStart] ) - 1
)
)
VAR NextName =
CALCULATE (
VALUES ( TableName[Name] ),
FILTER (
ALLEXCEPT ( TableName, TableName[Name] ),
TableName[SeriesStart]
= EARLIER ( TableName[SeriesStart] ) + 1
)
)
RETURN
IF (
PriorName <> TableName[Name],
"Series Start",
IF ( NextName <> TableName[Name], "Series End" )
)
- lkarolak8 years agoFrequent Visitor
Thank you Zubair_Muhammad, it almost works :)
This is the actual initial data that I have:
But then I get this after using the approach you suggested. The first row is exactly what I want, however, the "single" ones are still listed:
What am I doing wrong?
Thanks!
- Zubair_Muhammad8 years ago
Community Champion
- lkarolak8 years agoFrequent Visitor
Zubair_Muhammad My mistake, forgot to set the filter on visual level to match the "SeriesStart".
It's working good now, thanks a lot for your support!