Forum Discussion
Dates based on Slicer selection
- Anonymous1 year ago
Hi Jyaul1122 ,
Thank you for reaching out to Microsoft Fabric community.I got this working and thought I’d share how I did it,
I generated a separate slicer table from Fact[Data_Date] by creating a calculated table as shown below:
Slicer_Date = DISTINCT(Fact[Data_Date])There’s no relationship between this table and any other — it’s just used for the slicer.
Then I created a measure to check if each date in the matrix should be shown, based on the slicer selection:
Show Column = VAR SelectedDate = SELECTEDVALUE(Slicer_Date[Data_Date])
VAR ThisColumnDate = SELECTEDVALUE(Dates[Dates])
RETURN
IF (
NOT ISBLANK(SelectedDate) &&
NOT ISBLANK(ThisColumnDate) &&
ThisColumnDate,
1,
0
)And finally, this is the measure I used to get the actual date values in the matrix:
Selected Actual Date =
VAR SelectedDate = SELECTEDVALUE(Slicer_Date[Data_Date])
VAR ThisDate = SELECTEDVALUE(Dates[Dates])
VAR ThisProject = SELECTEDVALUE(Fact[Project])
RETURN
IF (
NOT ISBLANK(SelectedDate) &&
NOT ISBLANK(ThisDate) &&
NOT ISBLANK(ThisProject) &&
ThisDate <= SelectedDate,
CALCULATE (
MAX(Fact[Actual Date]),
FILTER (
Fact,
Fact[Project] = ThisProject &&
Fact[Data_Date] = ThisDate
)
)
)In the matrix, I placed Dates[Dates] on the rows, Fact[Project] on the columns, and used the Selected Actual Date measure as the value. I also applied Show Column as a visual-level filter, setting it to 1 so that only columns on or before the selected date are displayed.
The slicer uses the Slicer_Date table we set up initially.
Everything is functioning as intended the matrix updates according to the selected date and displays only the relevant values up to that point.
Please find the attached .pbix file for your reference
Regards,
Sreeteja.
Hi,
PBI file attached.
Hope this helps.
Thanks for the reply, but I have slicer from the Fact table[Data_Date], Please do needful .Thanks
- Ashish_Mathur1 year ago
Super User
You are welcome. That is not a good practise. You must always create a Calendar Table.