Forum Discussion
Filter Slicer from Measure values
Hi johnt75,
The new table did not work as start date is 31-12-1899 and the end date is blank.
I think is cause of the parameters used in the measures, when using them in a table, there is no context.
I tried modifying your code to use DATESBETWEEN() instead of CALENDAR(), it is not giving an error, but its not working either.
Anything else that you can think of?
You're right about the table lacking context. Try creating a table visual instead, use 'Date'[Date] and the two measures.
- visheshjain3 years agoImpactful Individual
- johnt753 years agoSuper User
That's the problem. You need to make sure that when step 1 and step 2 are calculated inside the date visible measure they get the same filters as are being applied in your card visuals.
- visheshjain3 years agoImpactful Individual
Hi johnt75,
Thank you for staying with me so far and responding instantly!
Okay. Done!
Solved the Step 1 and Step 2 problem.
Here is the current position:
I used the REMOVEFILTERS()/ALL() function and removed the filters from the Calendar Date column, so that only the last date of sales is considered.
And I used the above mentioned Date Visible measure on the slicer.
A weird thing was happeneing, that when I am using, DATESBETWEEN() function it works, not completely but it works, but when I use the calendar function to get the dates in between the start and end dates, it gives me an error, that the start date cannot be more than the end date.
- johnt753 years agoSuper User
I wonder if the problems are to do with it being the date table we're trying to filter. Instead of using IN you could try
Date is visible = IF ( SELECTEDVALUE ( 'Date'[Date] ) >= [2 Step] && SELECTEDVALUE ( 'Date'[Date] ) <= [1 Step], 1, 0 ) - visheshjain3 years agoImpactful Individual
Hi johnt75,
Tried and still not working.
Sharing a sample file for you to play around it if you will.
I tried this technique as well, but didn't seem to work. Have a look at it.
Create slicer with Custom Time Periods in PowerBI | Time Intelligence | MiTutorials - YouTube
Thank you!
- johnt753 years agoSuper User
Is Visible = VAR CurrentDate = MAX('Calendar'[Date]) VAR Step1 = [1 Step] VAR Step2 = [2 Step] RETURN IF( CurrentDate >= Step2 && CurrentDate <= Step1, 1, 0)gives the correct values in the table, but it doesn't play nicely with the slicer. If I add it as a filter on the slicer then you can't select any dates at all. Not sure what's going on.
- lbendlin3 years agoSuper User
Show your data model/post a sample pbix. Most likely the calendar table needs to be disconnected.
- visheshjain3 years agoImpactful Individual
Hi lbendlin,
I have shared a sample file in message 13 of the thread. Sharing it again in this post.
If the calendar table is diconnected, then it will not be able to filter out data from the fact tables.
Here is a look at the data model. It is quite basic.
- lbendlin3 years agoSuper User
Your measure are a little too complex. Use these instead:
1 Step = EOMONTH(CALCULATE ( MAX ( 'Sales'[Sale Date] ), ALL () ),-1) 2 Step = EOMONTH([1 Step], - [Parameter Value] ) + 1 - visheshjain3 years agoImpactful Individual
Hi lbendlin,
Changed the measures but still, its not working with filtering the slicer.
Attaching my file again.