Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have a Date Table and would like to Filter the Last 3 Months. This means if we are in the Month of December, there should be November, October and September all crumbled together as one item on a filter. How is this possible? Thanks.
Solved! Go to Solution.
Hi @Datagulf,
You can create an unconnected date table and use it as source slicer. Then you can write a measure formula to compare selected date and current date if it is including in the three months and use it on your visual to filter records.
Applying a measure filter in Power BI - SQLBI
formula =
VAR currDate =
MAX ( Table[Date] )
VAR selected =
MAX ( NewTable[Date] )
RETURN
IF (
currDate
>= DATE ( YEAR ( selected ), MONTH ( selected ) - 3, DAY ( selected ) )
&& currDate <= selected,
"Y",
"N"
)
Regards,
Xiaoxin Sheng
Hi @Datagulf,
You can create an unconnected date table and use it as source slicer. Then you can write a measure formula to compare selected date and current date if it is including in the three months and use it on your visual to filter records.
Applying a measure filter in Power BI - SQLBI
formula =
VAR currDate =
MAX ( Table[Date] )
VAR selected =
MAX ( NewTable[Date] )
RETURN
IF (
currDate
>= DATE ( YEAR ( selected ), MONTH ( selected ) - 3, DAY ( selected ) )
&& currDate <= selected,
"Y",
"N"
)
Regards,
Xiaoxin Sheng
Hi,
I am not sure how your datamodel looks like, but one of ways to solve this is using DATESINPERIOD DAX function.
For the StartDate parameter in the function, try using EOMONTH( TODAY(), -1) which gives end date of previous month.
I hope this helps.
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
150 | |
115 | |
104 | |
89 | |
65 |