Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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/
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
9 | |
8 | |
8 |
User | Count |
---|---|
14 | |
12 | |
11 | |
11 | |
8 |