Forum Discussion
How to Categorize Dates based on Relative Date Slicer
I have a report with a relative date slicer. Example:
I have created formulas for the min and max of those dates. Example:
Any help would be extemely useful. Thanks.
- Anonymous3 years ago
Hi Bjar2023 ,
Please have a try.
Create a table.
Period = {"Same Period last year","Selected Period"}Then create a measure.
PeriodValue = VAR _a = ALLSELECTED ( 'Date'[Date] ) VAR _b = SELECTCOLUMNS ( _a, "Last Year", EDATE ( [Date], -12 ) ) RETURN SUMX ( 'Period', SWITCH ( [Period], "Selected Period", SUMX ( FILTER ( 'Table', [date] IN _a ), [value] ), "Same Period last year", SUMX ( FILTER ( 'Table', [date] IN _b ), [value] ) ) )How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- AnonymousNot applicable
Hi Bjar2023 ,
I have created a simple sample, please refer to it to see if it helps you.
Create a measure.
Measure = var _maxdae=EDATE([Max Display Date],-12) var _mindate=EDATE([Min Display Date],-12) return IF(MAX('Table'[Date])<=[Max Display Date]&&MAX('Table'[Date])>=[Min Display Date],"Selected Period",IF(MAX('Table'[Date])<=_maxdae&&MAX('Table'[Date])>_mindate,"Same Period last year"))How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Bjar2023New Member
So this worked in categorizing the dates, but since its a measure, I cant create any sort of groupings from it. Ultimately, I want to sum metrics using this category. Example:
Total Revenue
Selected Period: $5,000
Same Period Last Year: $7,000
I may be oversimplifying, but is there an easy way to convert the measure to a column so I can create visuals from this grouping?
- AnonymousNot applicable
Hi Bjar2023 ,
Please have a try.
Create a table.
Period = {"Same Period last year","Selected Period"}Then create a measure.
PeriodValue = VAR _a = ALLSELECTED ( 'Date'[Date] ) VAR _b = SELECTCOLUMNS ( _a, "Last Year", EDATE ( [Date], -12 ) ) RETURN SUMX ( 'Period', SWITCH ( [Period], "Selected Period", SUMX ( FILTER ( 'Table', [date] IN _a ), [value] ), "Same Period last year", SUMX ( FILTER ( 'Table', [date] IN _b ), [value] ) ) )How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.