Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
I'm trying to create a date filter which will filter past 3 years data based on selection in a PBI matrix. The columns are the years. Below is a screenshot of how the marix looks like:
So if I select 2024 in date filter, it should display 2024, 2023 and 2022. if I select 2023, it should display 2023,2022, 2021. I realise there are previous posts similar to this, but they dont seem to work for matrix since I need to put Year in columns instead of values (previous results suggest creating a measure, which cannot go into pbi matrix column. only in values)
I have a separate date table which is related to all the other tables
Hi @adityah , hello All, thank you for your prompt reply!
Create a new calculated Date table as the slicer, then create a new measure as shown below:
past 3 years =
VAR data_year = YEAR(SELECTEDVALUE('FactTable'[date]))
VAR slicer_year = SELECTEDVALUE('DuplicateDate'[Date].[Year])
RETURN
IF(data_year<=slicer_year && data_year>slicer_year-3,
1,
0
)
Then add the measure to visual filter like this:
Result for your reference:
Best regards,
Joyce
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Create a new measure
Filtered Endorsements =
VAR SelectedYear = SELECTEDVALUE(DateTable[Year])
RETURN
CALCULATE(
SUM('YourDataTable'[Endorsements]),
FILTER(
ALL(DateTable),
DateTable[Year] >= SelectedYear - 2 && DateTable[Year] <= SelectedYear
)
)
💌 If this helped, a Kudos 👍 or Solution mark ✔️would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
hi @adityah ,
To achieve this, follow below process
1. create a separate calender dimention table covering all the dates in your dataset. dont create any relationship.
2. use this date in your slicer
3. now you need to create three different measures for "new", "endrosment","GWP" as per below syntax.
measure =
var start_year_Base =year( selectedvalue(dim_calender[date])]) - 2
var end_year_Base =year( selectedvalue(dim_calender[date])])
return
calculate (sum(table,[GWP]),year(table[date])>=start_year_base,year(table[date])<=end_year_base)
This should work. please share sample data if it fails.
Have a look at https://www.sqlbi.com/articles/show-previous-6-months-of-data-from-single-slicer-selection/ . By putting 'Previous Dates'[Year] in the matrix you should get the behaviour you are looking for.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
26 | |
20 | |
19 | |
14 | |
13 |
User | Count |
---|---|
43 | |
36 | |
24 | |
24 | |
22 |