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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
nehajadhav166
Resolver I
Resolver I

Get selected value from date slicer

Hi Experts,

 

I have date slicer like this

nehajadhav166_0-1661862012204.png

When I select value from slicer I want to capture that date range. I want to use this date range as part of other measure filter.

nehajadhav166_1-1661862074771.png

For example I want date range 1/10/2022 to 6/12/2022 and not min and max dates.

I tried selected value function but it did not work.

Any pointers here?

 

Thanks in advance.

 

Regards,

Neha

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @nehajadhav166 ,

Since you did not give a specific table, I had to create my own table for testing according to your description, please point out if there are any problems.

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1662088854830.png

Date Table(create from "Table" with dax):

 

Date Table = CALENDAR(FIRSTDATE('Table'[Date]),LASTDATE('Table'[Date]))

 

vbinbinyumsft_1-1662088888510.png

Model:

vbinbinyumsft_2-1662088906781.png

2. add a slicer with "Date Table[Date]",create a measure and add it to card visual

 

Sum for Sales =
VAR maxdate =
    MAXX ( ALLSELECTED ( 'Date Table'[Date] ), [Date] )
VAR mindate =
    MINX ( ALLSELECTED ( 'Date Table' ), [Date] )
VAR tmp =
    CALENDAR ( mindate, maxdate )
RETURN
    CALCULATE ( SUM ( 'Table'[Sales] ), tmp )

 

Animation9.gif

Please refer the attached .pbix file.

Best regards,
Community Support Team_ Binbin Yu
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

4 REPLIES 4
Anonymous
Not applicable

Hi @nehajadhav166 ,

Since you did not give a specific table, I had to create my own table for testing according to your description, please point out if there are any problems.

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1662088854830.png

Date Table(create from "Table" with dax):

 

Date Table = CALENDAR(FIRSTDATE('Table'[Date]),LASTDATE('Table'[Date]))

 

vbinbinyumsft_1-1662088888510.png

Model:

vbinbinyumsft_2-1662088906781.png

2. add a slicer with "Date Table[Date]",create a measure and add it to card visual

 

Sum for Sales =
VAR maxdate =
    MAXX ( ALLSELECTED ( 'Date Table'[Date] ), [Date] )
VAR mindate =
    MINX ( ALLSELECTED ( 'Date Table' ), [Date] )
VAR tmp =
    CALENDAR ( mindate, maxdate )
RETURN
    CALCULATE ( SUM ( 'Table'[Sales] ), tmp )

 

Animation9.gif

Please refer the attached .pbix file.

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Anonymous ,

Thank you for reply.

I tried this approch and it worked for me.

Var selected_maxdate=IF.EAGER( (ISFILTERED ( 'TestData'[Date] )),MAX ( 'TestData'[Date] ),MAX(TestData[Date]))
Var selected_mindate=IF.EAGER( (ISFILTERED ( 'TestData'[Date] )),MIN ( 'TestData'[Date] ),MIN(TestData[Date]))
 
Allselected and min/max did not wor for me.
Thanks,
Neha
nehajadhav166
Resolver I
Resolver I

Hi Amit,

Thanks for quick reply.

I do not understand how countrows will help to get values selected from date slicer?

Can you please elaborate?

 

Thanks,

Neha

amitchandak
Super User
Super User

@nehajadhav166 ,

 

Measure =

var _tab = values(date[Date])

return

countrows(filter(Table, Table[Date] in _tab) )

 

Or between

 

new measure =
var _max = maxx(allselected(Date),Date[Date])
var _min = minx(allselected(Date),Date[Date])
return
calculate( sum(Table[Value]), filter('Table', 'Table'[Date] >=_min && 'Table'[Date] <=_max))

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.