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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
PowerBI101
Frequent Visitor

Extract and use slicer value as a filter for DAX formula (measure)?

My report consists of a line chart that is controlled by a date slicer (you pick the start and end date) and a few measures.

 

I have no issues with the line chart, but I would like to use the date slicer as a filter in the measure calculations. One measure could be called yearly incidents, where I use COUNTROWS() and some filters to calculate the incidents over a specific time period.

 

I would like to display the yearly number of incidents and this year would be controlled by the date slicer. For example, picking a end date of 30.5.2019 would select 2019 to be used as the filter and the measure calculation would include all events from this year (until today). Even if we picked a start date of 1.5.2019, the measure still needs to display all incidents from this year. So, the date slicer can't be linked to the measure card in interactions.

 

I tried to extract the year by using 

YEAR(LASTDATE(ALLSELECTED('Date'[Date]))), but it did not work (always returns the last year in my Date table). I assume that after I can correctly extract the ending year, I can use https://community.powerbi.com/t5/Desktop/Using-a-Measure-as-a-filter-in-DAX-formula/td-p/395330 to create the calculation.

 

What would be the best way to implement this? I'm using DirectQuery if that impacts something (I could always switch over to Import if needed).

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

In the filter portion of the CALCULATE() function, try this

DATESBETWEEN('Date'[Date],DATE(YEAR(MIN('Date'[Date])),1,1),TODAY())

Does this work?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @PowerBI101 ,

Have you solved your problem?

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

If you still need help, please share your data sample and your desired output.

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

In the filter portion of the CALCULATE() function, try this

DATESBETWEEN('Date'[Date],DATE(YEAR(MIN('Date'[Date])),1,1),TODAY())

Does this work?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @PowerBI101 ,

To understand your scenario better, could you share some data sample which could reproduce the scenario and your desired output so that we could help further on it?

Best Regards,

Cherry

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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