Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a calculated measure that gives me the 5th Previous Month from now (March 2024) in this format. How do I use this value to filter a table to show only data from that particular Month and Year?
Here is a demo table. As the current month is August, the 5th previous month will be March, so I would like to display data for that month. Next month, the 5th Month will change to April, and so on.
Number | Date | Person |
1 | 1/1/2024 | xyz |
2 | 1/2/2024 | abc |
3 | 3/2/2024 | pqr |
4 | 3/3/2024 | ijk |
5 | 4/1/2024 | xyz |
Solved! Go to Solution.
Hi @monishd ,
You can create a measure as below, then apply it to visual filter.
PeriodFilter =
VAR CurRowDateMonth = FORMAT(MAX('Table'[Date]),"yyyymm")
VAR Pre5thMonth = FORMAT(EDATE(NOW(),-5),"yyyymm")
RETURN
IF(CurRowDateMonth = Pre5thMonth,1,0)
Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !
Thank you~
Hi @monishd ,
You can create a measure as below, then apply it to visual filter.
PeriodFilter =
VAR CurRowDateMonth = FORMAT(MAX('Table'[Date]),"yyyymm")
VAR Pre5thMonth = FORMAT(EDATE(NOW(),-5),"yyyymm")
RETURN
IF(CurRowDateMonth = Pre5thMonth,1,0)
Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !
Thank you~
To dynamically filter a table visual in Power BI using a calculated measure that determines the 5th previous month, follow these steps:
Create a Date Table (if not already present):
DateTable = CALENDAR(MIN('YourDataTable'[Date]), MAX('YourDataTable'[Date]))
Create the Calculated Measure:
FifthPreviousMonth =
FORMAT(
EDATE(TODAY(), -5),
"MMMM YYYY"
)
Add a Calculated Column to Identify the Month-Year:
MonthYear = FORMAT('DateTable'[Date], "MMMM YYYY")
Apply the Filter Using the Measure:
By doing this, the table visual will automatically filter to show only the records from the 5th previous month, regardless of when the report is viewed.
Thank you for the quick reply. I have completed all steps except for the last one, i.e.,
Apply the Filter Using the Measure:
How do I filter MonthYear = FifthPreviousMonth ?
To filter your MonthYear column using the FifthPreviousMonth measure in Power BI, you can follow these steps:
This setup dynamically filters your table to show only the rows from the desired month and will adjust as the current month changes.
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
10 | |
6 |