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.
How to filter a date and use a measure remove that previous filter?
For example: If I filter January show me all itens in my table that have a January date, but if I filter February I need to see all itens from January and February, if select March see all itens from January to March.
I tried this code but didn't have success.
SWITCH(TRUE(),
SELECTEDVALUE(MyTable[PlannedMonth])="January", CALCULATE(COUNTA(MyTable[PlannedMonth]), ALL(MyTable[PlannedMonth]), MyTable[End Date]<=DATEVALUE("31/01/2022")),
SELECTEDVALUE(MyTable[PlannedMonth])="February", CALCULATE(COUNTA(MyTable[PlannedMonth]), ALL(MyTable[PlannedMonth]), MyTable[End Date]<=DATEVALUE("28/02/2022"))
Where the column "PlannedMonth" are the month name and "End Date" are my numerical dates
Solved! Go to Solution.
Hi @Anonymous ,
According to your description, I create a sample.
If you want to count the number of days less than or equal to the selected month, in my sample your formula works.
If you want to display all dates from January and February when you filter February, here's my solution.
1. Create a new month table, don't make relationship between the two tables.
2.Create a measure.
Check =
IF (
MAX ( 'MyTable'[End Date] )
<= MAXX (
FILTER (
ALL ( 'MyTable' ),
FORMAT ( 'MyTable'[End Date], "MMMM" ) = SELECTEDVALUE ( 'Month'[Month] )
),
'MyTable'[End Date]
),
1
)
Put the new month column in a slicer and put the measure in the visual filter and select its value to 1, get the result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
According to your description, I create a sample.
If you want to count the number of days less than or equal to the selected month, in my sample your formula works.
If you want to display all dates from January and February when you filter February, here's my solution.
1. Create a new month table, don't make relationship between the two tables.
2.Create a measure.
Check =
IF (
MAX ( 'MyTable'[End Date] )
<= MAXX (
FILTER (
ALL ( 'MyTable' ),
FORMAT ( 'MyTable'[End Date], "MMMM" ) = SELECTEDVALUE ( 'Month'[Month] )
),
'MyTable'[End Date]
),
1
)
Put the new month column in a slicer and put the measure in the visual filter and select its value to 1, get the result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous follow this patten and you'll solve your question and much more 🙂
https://www.daxpatterns.com/standard-time-related-calculations/
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
22 | |
7 | |
6 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |