Hi there,
I am trying to create a date slicer that contains 4 different options i.e. Today, Yesterday, 7 days, and 10 days option. I want to filter my other measures based on these 4 options. I created a table using following code for to have these dates:
let
TodaysDate = Date.From(DateTimeZone.LocalNow()),
Ranges = {
{“Today”, TodaysDate, TodaysDate, 1},
{“Yesterday”, Date.AddDays(TodaysDate, -1), Date.AddDays(TodaysDate, -1), 2},
{“Last 7 Days”, Date.AddDays(TodaysDate, -6), TodaysDate, 3}, // last 7 days including Today
{“Last 10 Days”, Date.AddDays(TodaysDate, -9), TodaysDate, 4}
},
fxCreatePeriodTabe = ( PeriodName as text, StartDate as date, EndDate as date, SortOrder as number ) as table =>
let
DayCount = Duration.Days(EndDate-StartDate)+1,
DateList = List.Dates(StartDate,DayCount,#duration(1,0,0,0)),
AddPeriodName = List.Transform(DateList, each {PeriodName,_,SortOrder}),
CreateTable = #table( type table[Period=text, Date=date, Sort=number], AddPeriodName)
in
CreateTable,
GetTables = List.Transform(Ranges, each fxCreatePeriodTabe(_{0}, _{1}, _{2}, _{3})),
Output = Table.Combine(GetTables)
in
Output
I connected the above table with date table and main fact table as shown in the picture:
I used one of the field of the date slicer table to create drop-down list as shown in the following picture:
When I choose the date value from the drop-down list it does not make any impact on the card visuals. I am not sure where am I making the mistake? Could anyone help me in fixing the issue. Sample file here
sample_data.pbix (734.0 KB)