Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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/