Forum Discussion
rogerdea
1 year agoHelper IV
Creating filter where date value can fall into different buckets
I want to create a filter for "next 7 days" and also "next 14 days", where a date might fall into both categories. Been trying to do this a while without success, i had the following code as an appr...
- 1 year ago
Create a new table like
Time Period Slicer = SELECTCOLUMNS ( UNION ( GENERATE ( { "Next 7 Days" }, DATESINPERIOD ( dim_date_bi[date], TODAY (), 7, DAY ) ), GENERATE ( { "Next 14 Days" }, DATESINPERIOD ( dim_date_bi[date], TODAY (), 14, DAY ) ) ), "Period", [Value1], "Date", [Value2] )Create a many-to-many relationship from the new table to your date table, single direction so that the new table filters date, not the other way around.
Use the new table in your slicer.
johnt75
1 year agoSuper User
Create a new table like
Time Period Slicer =
SELECTCOLUMNS (
UNION (
GENERATE (
{ "Next 7 Days" },
DATESINPERIOD ( dim_date_bi[date], TODAY (), 7, DAY )
),
GENERATE (
{ "Next 14 Days" },
DATESINPERIOD ( dim_date_bi[date], TODAY (), 14, DAY )
)
),
"Period", [Value1],
"Date", [Value2]
)
Create a many-to-many relationship from the new table to your date table, single direction so that the new table filters date, not the other way around.
Use the new table in your slicer.