Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Fabric Community site will be in read-only mode on Monday, Feb 24 from 12:01 AM to 8 AM PST for scheduled upgrades.

Reply
Velocity
Helper III
Helper III

Can I use a Measure in Filter?

Hi,

In my data table, i have many records with future dates. I would like to restrict my slicer to show dates up to last week's beginning date. I have created a measure

cutoff date = today() - (weekday(today(),2) - 6)

Now, i want to show only those dates in filter where transaction date is less that cutoff date but it seems you can't use a measure in visual or page or all pages filter. Any suggestions?

 

Thanks.

 

1 ACCEPTED SOLUTION
rajulshah
Memorable Member
Memorable Member

Hello @Velocitym,

 

You can use a measure as 'Visual Level Filter'. However you can create a calculated column in the date table that returns zero for the days that you don't want to count in the measure.

 

On the basis of what I think your requirement is, I have created a calculated column as below:

 

Last Week StartDay = 
VAR CurrentWeek =  WEEKNUM(TODAY())
VAR LastWeek = CurrentWeek-1
VAR LastWeekBeginningDate = CALCULATE(FIRSTDATE('Date'[Date]),FILTER('Date',WEEKNUM('Date'[Date])=LastWeek))
RETURN IF(WEEKNUM('Date'[Date])>=LastWeek && 'Date'[Date]>LastWeekBeginningDate,1,0)

 

And you can use this colujmn to filter out the dates, as LastWeekStartDay<>1.

You can modify the start of the day as you want. I have taken the default start of the week.
Hope this helps. Please let me know if this doesn't work.

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Velocity ,Visual level filter should allow measure. Slicer and page-level will not

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak

 

I guessed as much. Hence, i had created a calculated column to achieve what i was trying.

 

Thanks.

hi  @Velocity 

First, you should know that:

1. Calculation column not support dynamic changed based on filter or slicer.
2. Measure can be affected by filter/slicer, so you can use it to get dynamic summary result.

https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

 

So you could not use a measure as a slicer.

"I guessed as much. Hence, i had created a calculated column to achieve what i was trying."  It's pleasant that your problem has been solved, 😁 please accept the reply as solution, that way, other community members will easily find the solution when they get same issue.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
rajulshah
Memorable Member
Memorable Member

Hello @Velocitym,

 

You can use a measure as 'Visual Level Filter'. However you can create a calculated column in the date table that returns zero for the days that you don't want to count in the measure.

 

On the basis of what I think your requirement is, I have created a calculated column as below:

 

Last Week StartDay = 
VAR CurrentWeek =  WEEKNUM(TODAY())
VAR LastWeek = CurrentWeek-1
VAR LastWeekBeginningDate = CALCULATE(FIRSTDATE('Date'[Date]),FILTER('Date',WEEKNUM('Date'[Date])=LastWeek))
RETURN IF(WEEKNUM('Date'[Date])>=LastWeek && 'Date'[Date]>LastWeekBeginningDate,1,0)

 

And you can use this colujmn to filter out the dates, as LastWeekStartDay<>1.

You can modify the start of the day as you want. I have taken the default start of the week.
Hope this helps. Please let me know if this doesn't work.

Hello @rajulshah

 

I had already worked out Calculated Column solution but was hoping for 'Measure' solution.

 

Thanks for your input. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.