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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to create a measure relative to date slicer to filter data out of the slicer scope ?

Hi everybody,

 

Brand new to Power BI I have been strugling with my problem for 2 weeks now.

This is my 1st post to the Comumunity, hope someone could help, and sorry for my english (not my native langage 😅)

 

My problem is in the subject : I would like to create a measure relative to date slicer in order to filter data out of the slicer scope.

 

I have a table containing server data logs.

I need to build a report containing differents graphics

My report contains a date based slicer

Some of the graphics have to show data from previouses monthes relative to the date picked in the slicer

 

Eg: if "April" is picked in the slicer, my graphic has to show the number of rows relative to March, if "March" is picked in the slicer, my graphic has to show the number of rows relative to February, and so on

 

I created a mesure to get the selected month from the slicer :

CustomDate = MAX(Table[Date])
 
and another one to get the number of rows based on the CustomDate measure (less one month) :
CustomDatePreviousMonthTotalLines =
CALCULATE(
COUNTROWS(Table),
FILTER(
Table,
MONTH(Table[Date]) = MONTH([CustomDate]) -1
)
)
 
But this doesn't work, may be I have to use some yet unknown functions..
 
Thanks for you help, thanks for your time 🙂
 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try like

 

CustomDate = MAXX(allselected(Table), Table[Date])

 

CustomDatePreviousMonthTotalLines =
CALCULATE(
COUNTROWS(Table),
FILTER(
Table,
EOMONTH(Table[Date],0) = Eomonth([CustomDate], -1)
)
)

 

But you might need all

 

CustomDatePreviousMonthTotalLines =
CALCULATE(
COUNTROWS(Table),
FILTER(
all(Table),
EOMONTH(Table[Date],0) = Eomonth([CustomDate], -1)
)
)

-----

 

These calculation best work with date table
CustomDate = MAXX(allselected(Date), Date[Date])

 

CustomDatePreviousMonthTotalLines =
CALCULATE(
COUNTROWS(Date),
FILTER(
all(Date),
EOMONTH(Date[Date],0) = Eomonth([CustomDate], -1)
)
)

 

 

Better to use time intelligence

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Try like

 

CustomDate = MAXX(allselected(Table), Table[Date])

 

CustomDatePreviousMonthTotalLines =
CALCULATE(
COUNTROWS(Table),
FILTER(
Table,
EOMONTH(Table[Date],0) = Eomonth([CustomDate], -1)
)
)

 

But you might need all

 

CustomDatePreviousMonthTotalLines =
CALCULATE(
COUNTROWS(Table),
FILTER(
all(Table),
EOMONTH(Table[Date],0) = Eomonth([CustomDate], -1)
)
)

-----

 

These calculation best work with date table
CustomDate = MAXX(allselected(Date), Date[Date])

 

CustomDatePreviousMonthTotalLines =
CALCULATE(
COUNTROWS(Date),
FILTER(
all(Date),
EOMONTH(Date[Date],0) = Eomonth([CustomDate], -1)
)
)

 

 

Better to use time intelligence

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi,

Thanks for your help it's work fine 👍

I will take a look to the links you mentionned

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors