Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi,
By default, I want to select the current year and the month prior to the current month in the filter. How can I accomplish this?
Thank you.
Solved! Go to Solution.
Hi @Abrar786,
You could create such a calculated column in your calendar table and use the filter [Target Month] = "yes" in your filter.
In plain text for convenience:
Target Month =
VAR TargetMonth = MONTH ( TODAY() ) - 1
VAR TargetYear = YEAR ( TODAY () )
RETURN IF ( MONTH ( [Date] ) = TargetMonth && YEAR ( [Date] ) = TargetYear, "yes", "no" )Best Regards,
Alexander
Hi @Abrar786
The below columns should resolve your concern. Just add the below columns to your filters.
1. Year = IF(YEAR('Table'[Date]) = YEAR(TODAY()),"Current Year",FORMAT('Table'[Date],"YYYY"))
2. Month = IF(MONTH('Table'[Date]) = MONTH(TODAY())-1,"Previous Month of Current Year",FORMAT('Table'[Date],"mmm"))
Thanks,
Hamed
https://www.linkedin.com/in/hamed-mohammed-6aa073197/
Hi @Abrar786,
Forgot to mention, if you plan to continue using your report in January, you may need to adjust the measure:
Target Month =
VAR CurrentMonth = MONTH ( TODAY() )
VAR TargetMonth = IF ( CurrentMonth = 1, 12, CurrentMonth - 1 )
VAR TargetYear = IF ( CurrentMonth = 1, YEAR ( TODAY () ) - 1, YEAR ( TODAY () ) )
RETURN IF ( MONTH ( [Date] ) = TargetMonth && YEAR ( [Date] ) = TargetYear, "yes", "no" )Best Regards,
Alexander
Hi @Abrar786
The below columns should resolve your concern. Just add the below columns to your filters.
1. Year = IF(YEAR('Table'[Date]) = YEAR(TODAY()),"Current Year",FORMAT('Table'[Date],"YYYY"))
2. Month = IF(MONTH('Table'[Date]) = MONTH(TODAY())-1,"Previous Month of Current Year",FORMAT('Table'[Date],"mmm"))
Thanks,
Hamed
https://www.linkedin.com/in/hamed-mohammed-6aa073197/
Hi @barritown ,
Thank you for the response. Using your approach, I am currently retrieving 'yes' or 'no' values in the filter. However, I would like the filter to display 'prior month' and 'current year' as the default options that are already checked by default.
Please let me know if you need any further assistance!
Hi @Abrar786,
I supposed you want to show data for the previous month of the current year on your dashbord.
My solution marks all the days of the previous month of the current year with "yes". So if you leave only this new filter with "yes", you will get data for the previous month only and your "Month Name" filter will contain only May. If you want to access other months, you must select "No" - your "Month Name" filter will contain all the months but May.
Best Regards,
Alexander
Hi @barritown ,
I am looking for a solution where users don't have to select anything. Whenever they open the report, it should display the default as the current year and the prior month's report without requiring any manual selection.
Hi @Abrar786,
Even better, please try to remove all the filters except the new one, select "yes" there - you will get the previous month of the current year on the dashboard.
Best Regards,
Alexander
Hi @Abrar786,
You could create such a calculated column in your calendar table and use the filter [Target Month] = "yes" in your filter.
In plain text for convenience:
Target Month =
VAR TargetMonth = MONTH ( TODAY() ) - 1
VAR TargetYear = YEAR ( TODAY () )
RETURN IF ( MONTH ( [Date] ) = TargetMonth && YEAR ( [Date] ) = TargetYear, "yes", "no" )Best Regards,
Alexander
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.