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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Learner22
Helper I
Helper I

How can I link a measure with a date slicer

Dear Commnity,

 

I have a measure like this

 

Number of Requests

20.000

Date from until now (for example 01/01/2021 until 11/21/2022)

 

And I have a date slicer for the last 2 years and months. For example, if I select the month September from the year 2022 the year 2022 then I want that Date from should be replaced by the selected date.

My meausure should look like this

 

Number of requests

500

September 2022 until 11/21/2022.

 

How can I do this?

 

Thank you very much.

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Learner22 ,

I created some data:

vyangliumsft_0-1669187753640.png

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
CALENDAR(
    DATE(2020,1,1),DATE(2022,12,31))

2. Create measure.

Measure =
var _selectyear=SELECTEDVALUE('Table 2'[Date].[Year])
var _selectmonth=SELECTEDVALUE('Table 2'[Date].[Month])
var _monthnumber=MAXX(FILTER(ALL('Table 2'),
FORMAT('Table 2'[Date],"mmmm")=_selectmonth),MONTH('Table 2'[Date]))
return
SUMX(FILTER(ALL('Table'),'Table'[Date]>=DATE(_selectyear,_monthnumber,1)&&'Table'[Date]<=TODAY()),[Value])

3. Result:

vyangliumsft_1-1669187753643.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @Learner22 ,

I created some data:

vyangliumsft_0-1669187753640.png

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
CALENDAR(
    DATE(2020,1,1),DATE(2022,12,31))

2. Create measure.

Measure =
var _selectyear=SELECTEDVALUE('Table 2'[Date].[Year])
var _selectmonth=SELECTEDVALUE('Table 2'[Date].[Month])
var _monthnumber=MAXX(FILTER(ALL('Table 2'),
FORMAT('Table 2'[Date],"mmmm")=_selectmonth),MONTH('Table 2'[Date]))
return
SUMX(FILTER(ALL('Table'),'Table'[Date]>=DATE(_selectyear,_monthnumber,1)&&'Table'[Date]<=TODAY()),[Value])

3. Result:

vyangliumsft_1-1669187753643.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

FreemanZ
Super User
Super User

yes, DATESBETWEEN function allows to pinpoint the start and end date of your calculation. 

the start date in your case seems MAX(the column you put to slicer) and the end date you can put it TODAY().

Sorry, this doesn't work. If I select a specific month, the measure doesn't reflect that.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors